2008-06-30 11:54:10 -07:00
|
|
|
Cu.import("resource://weave/dav.js");
|
2008-06-30 11:18:16 -07:00
|
|
|
Cu.import("resource://weave/async.js");
|
|
|
|
Cu.import("resource://weave/crypto.js");
|
|
|
|
Cu.import("resource://weave/identity.js");
|
|
|
|
Function.prototype.async = Async.sugar;
|
|
|
|
|
2008-06-30 11:54:10 -07:00
|
|
|
let __fakeCryptoID = {
|
|
|
|
keypairAlg: "RSA",
|
2008-06-30 14:29:26 -07:00
|
|
|
// This private key is encrypted with the passphrase 'passphrase',
|
|
|
|
// contained in our testing infrastructure.
|
2008-06-30 11:54:10 -07:00
|
|
|
privkey: "3ytj94K6Wo0mBjAVsiIwjm5x2+ENvpKTDUqLCz19iXbESf8RT6O8PmY7Pqcndpn+adqaQdvmr0T1JQ5bfLEHev0WBfo8oWJb+OS4rKoCWxDNzGwrOlW5hCfxSekw0KrKjqZyDZ0hT1Qt9vn6thlV2v9YWfmyn0OIxNC9hUqGwU3Wb2F2ejM0Tw40+IIW4eLEvFxLGv0vnEXpZvesPt413proL6FGQJe6vyapBg+sdX1JMYGaKZY84PUGIiDPxTbQg7yIWTSe3WlDhJ001khFiyEoTZvPhiAGXfML9ycrCRZUWkHp/cfS7QiusJXs6co0tLjrIk/rTk8h4mHBnyPkFIxh4YrfC7Bwf9npwomhaZCEQ32VK+a8grTDsGYHPZexDm3TcD2+d+hZ/u4lUOHFscQKX4w83tq942yqFtElCD2yQoqEDr1Z9zge5XBnLcYiH9hL0ozfpxBlTtpR1kSH663JHqlYim0qhuk0zrGAPkHna07UMFufxvgQBSd/YUqWCimJFGi+5QeOOFO20Skj882Bh1QDYsmbxZ/JED5ocGNHWSqpaOL2ML1F9nD5rdtffI0BsTe+j9h+HV4GlvzUz0Jd6RRf9xN4RyxqfENb8iGH5Pwbry7Qyk16rfm0s6JgG8pNb/8quKD+87RAtQFybZtdQ9NfGg+gyRiU9pbb6FPuPnGp+KpktaHu/K3HnomrVUoyLQALfCSbPXg2D9ta6dR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EFAAOCAQ8AMIIBCgKCAQEAxxwObnXIoYeQKMG9RbvLkgsu/idDo25qOX87jIEiXkgW1wLKp/1D/DBLUEW303tVszNGVt6bTyAXOIj6skpmYoDs9Z48kvU3+g7Vi4QXEw5moSS4fr+yFpKiYd2Kx1+jCFGvGZjBzAAvnjsWmWrSA+LHJSrFlKY6SM3kNg8KrE8dxUi3wztlZnhZgo1ZYe7/VeBOXUfThtoadIl1VdREw2e79eiMQpPa0XLv4grCaMd/wLRs0be1/nPt7li4NyT0fnYFWg75SU3ni/xSaq/zR4NmW/of5vB2EcKyUG+/mvNplQ0CX+v3hRBCdhpCyPmcbHKUluyKzj7Ms9pKyCkwxwIDAQAB"
|
|
|
|
};
|
|
|
|
|
2008-06-30 14:29:26 -07:00
|
|
|
function testGenerator() {
|
|
|
|
let self = yield;
|
2008-06-30 11:18:16 -07:00
|
|
|
|
2008-06-30 11:54:10 -07:00
|
|
|
let id = ID.get("WeaveCryptoID");
|
|
|
|
for (name in __fakeCryptoID)
|
|
|
|
id[name] = __fakeCryptoID[name];
|
2008-06-30 11:18:16 -07:00
|
|
|
|
2008-06-30 14:40:11 -07:00
|
|
|
Crypto.isPassphraseValid.async(Crypto, self.cb, id);
|
2008-06-30 14:29:26 -07:00
|
|
|
let result = yield;
|
|
|
|
|
|
|
|
do_check_eq(result, true);
|
|
|
|
|
|
|
|
id.setTempPassword("incorrect passphrase");
|
|
|
|
|
2008-06-30 14:40:11 -07:00
|
|
|
Crypto.isPassphraseValid.async(Crypto, self.cb, id);
|
2008-06-30 14:29:26 -07:00
|
|
|
result = yield;
|
|
|
|
|
|
|
|
do_check_eq(result, false);
|
|
|
|
|
|
|
|
self.done();
|
|
|
|
}
|
|
|
|
|
|
|
|
function run_test() {
|
|
|
|
let syncTesting = new SyncTestingInfrastructure();
|
2008-06-30 11:18:16 -07:00
|
|
|
|
2008-06-30 14:29:26 -07:00
|
|
|
syncTesting.runAsyncFunc(
|
|
|
|
"Ensuring isPassphraseValid() works",
|
|
|
|
function runTest(cb) { testGenerator.async({}, cb); }
|
|
|
|
);
|
2008-06-30 11:18:16 -07:00
|
|
|
}
|