mirror of
https://github.com/amark/gun.git
synced 2025-06-07 22:56:42 +00:00
SEA User.auth test cases done & bug fixed
This commit is contained in:
parent
b74a0268d0
commit
68f5725899
6
sea.js
6
sea.js
@ -140,7 +140,7 @@
|
||||
root.get(key).get(function(at, ev){
|
||||
key = key.slice(4);
|
||||
ev.off();
|
||||
if(!at.put){ return reject({err: 'Public key does not exist!'}) }
|
||||
if(!at.put){return}
|
||||
// attempt to PBKDF2 extend the password with the salt. (Verifying the signature gives us the plain text salt.)
|
||||
SEA.read(at.put.salt, key).then(function(salt){
|
||||
return SEA.proof(pass, salt);
|
||||
@ -198,10 +198,14 @@
|
||||
return;
|
||||
}
|
||||
// Or else we failed to log in...
|
||||
}).catch(function(e){
|
||||
Gun.log('Failed to sign in!');
|
||||
reject({err: 'Attempt failed'});
|
||||
});
|
||||
});
|
||||
// if (!found) {
|
||||
// reject({err: 'Public key does not exist!'})
|
||||
// }
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -8038,6 +8038,7 @@ describe('Gun', function(){
|
||||
var alias = 'dude';
|
||||
var pass = 'my secret password';
|
||||
var user = Gun().user();
|
||||
Gun.log.off = true; // Supress all console logging
|
||||
|
||||
['callback', 'Promise'].forEach(function(type){
|
||||
describe(type, function(){
|
||||
@ -8057,8 +8058,7 @@ describe('Gun', function(){
|
||||
}
|
||||
});
|
||||
it('conflict', function(done){
|
||||
var gunLog = Gun.log; // Temporarily removing logging
|
||||
Gun.log = function(){};
|
||||
Gun.log.off = true; // Supress all console logging
|
||||
var check = function(ack){
|
||||
expect(ack).to.not.be(undefined);
|
||||
expect(ack).to.not.be('');
|
||||
@ -8075,7 +8075,6 @@ describe('Gun', function(){
|
||||
done('Failed to decline creating existing user!');
|
||||
}).catch(check);
|
||||
}
|
||||
Gun.log = gunLog;
|
||||
});
|
||||
});
|
||||
|
||||
@ -8087,28 +8086,86 @@ describe('Gun', function(){
|
||||
expect(ack).to.not.have.key('err');
|
||||
done();
|
||||
};
|
||||
var props = {alias: alias+'-'+type, pass: pass};
|
||||
user.create(props.alias, props.pass).catch(function(){})
|
||||
.then(function(){
|
||||
// Gun.user.create - creates new user
|
||||
var props = {alias: alias+type, pass: pass};
|
||||
// Gun.user.auth - authenticates existing user
|
||||
if(type === 'callback'){
|
||||
user.auth(props, check);
|
||||
} else {
|
||||
user.auth(props).then(check).catch(done);
|
||||
}
|
||||
});
|
||||
|
||||
it('wrong password', function(done){
|
||||
var check = function(ack){
|
||||
expect(ack).to.not.be(undefined);
|
||||
expect(ack).to.not.be('');
|
||||
expect(ack).to.have.key('err');
|
||||
expect(ack.err).to.not.be(undefined);
|
||||
expect(ack.err).to.not.be('');
|
||||
done();
|
||||
};
|
||||
var props = {alias: alias+type, pass: pass+'not'};
|
||||
if(type === 'callback'){
|
||||
user.auth(props, check);
|
||||
} else {
|
||||
user.auth(props).then(function(ack){
|
||||
done('Unexpected login success!');
|
||||
}).catch(check);
|
||||
}
|
||||
});
|
||||
|
||||
it.skip('failed login', function(done){
|
||||
it('unknown alias', function(done){
|
||||
var check = function(ack){
|
||||
expect(ack).to.not.be(undefined);
|
||||
expect(ack).to.not.be('');
|
||||
expect(ack).to.have.key('err');
|
||||
expect(ack.err).to.not.be(undefined);
|
||||
expect(ack.err).to.not.be('');
|
||||
done();
|
||||
};
|
||||
var props = {alias: alias+type+'not', pass: pass};
|
||||
if(type === 'callback'){
|
||||
user.auth(props, check);
|
||||
} else {
|
||||
user.auth(props).then(function(ack){
|
||||
done('Unexpected login success!');
|
||||
}).catch(check);
|
||||
}
|
||||
});
|
||||
|
||||
it.skip('new password', function(done){
|
||||
it('new password', function(done){
|
||||
var check = function(ack){
|
||||
expect(ack).to.not.be(undefined);
|
||||
expect(ack).to.not.be('');
|
||||
expect(ack).to.not.have.key('err');
|
||||
done();
|
||||
};
|
||||
var props = {alias: alias+type, pass: pass, newpass: pass+' new'};
|
||||
// Gun.user.auth - with newpass props sets new password
|
||||
if(type === 'callback'){
|
||||
user.auth(props, check);
|
||||
} else {
|
||||
user.auth(props).then(check).catch(done);
|
||||
}
|
||||
});
|
||||
|
||||
it.skip('failed new password', function(done){
|
||||
it('failed new password', function(done){
|
||||
var check = function(ack){
|
||||
expect(ack).to.not.be(undefined);
|
||||
expect(ack).to.not.be('');
|
||||
expect(ack).to.have.key('err');
|
||||
expect(ack.err).to.not.be(undefined);
|
||||
expect(ack.err).to.not.be('');
|
||||
done();
|
||||
};
|
||||
var props = {alias: alias+type, pass: pass+'not', newpass: pass+' new'};
|
||||
if(type === 'callback'){
|
||||
user.auth(props, check);
|
||||
} else {
|
||||
user.auth(props).then(function(ack){
|
||||
done('Unexpected password change success!');
|
||||
}).catch(check);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -8119,6 +8176,7 @@ describe('Gun', function(){
|
||||
});
|
||||
});
|
||||
});
|
||||
Gun.log.off = false;
|
||||
});
|
||||
|
||||
describe('Streams', function(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user