This commit is contained in:
Mark Nadal
2021-08-21 20:03:09 -07:00
parent 824319afab
commit cdca88e60b
11 changed files with 59 additions and 15457 deletions

View File

@@ -5,6 +5,9 @@ const http = require("http");
require("../../lib/promise");
let gunClient, server;
// MOVED TO SEA!!!!!!!
describe("SEA node client auth", () => {
it("should start server", done => {
server = http.createServer().listen(8765, done);
@@ -22,7 +25,7 @@ describe("SEA node client auth", () => {
it("should create user", done => {
gunClient.user().create("gun", "password", res => {
console.log({ res });
//console.log({ res });
expect(res.err).to.equal(undefined);
done();
});
@@ -46,10 +49,10 @@ describe("SEA node client auth", () => {
});
});
xit("should not stuck on null node", async () => {
it("should not stuck on null node", async () => {
const r1 = await gunClient
.user()
.once(console.log)
//.once(console.log)
.get("test")
.promPut({ z: 1 });

View File

@@ -523,7 +523,7 @@ describe('SEA', function(){
expect(g[p+'/zfdsa/y'].x.indexOf('/zfdsa/y/x"') > 0).to.be.ok();
expect(g[p+'/zfdsa/y/x'].c.indexOf('/zasdf"') > 0).to.be.ok();
done();
},500)};
},100)};
});
gun.user().auth(alice);
});
@@ -601,7 +601,7 @@ describe('SEA', function(){
it('Certify: Attack', function(done){(async function(){
var alice = await SEA.pair()
var bob = await SEA.pair()
var cert = await SEA.certify(bob, {"*": "private"}, alice)
var cert = await SEA.certify(bob, {"*": "private"}, alice);
user.leave()
user.auth(bob, () => {
@@ -622,7 +622,6 @@ describe('SEA', function(){
var alice = await SEA.pair()
var bob = await SEA.pair()
var cert = await SEA.certify('*', [{"*": "test", "+": "*"}, {"*": "inbox", "+": "*"}], alice)
user.leave()
user.auth(bob, () => {
var data = Gun.state().toString(36)
@@ -635,7 +634,7 @@ describe('SEA', function(){
done()
}, { opt: { cert } })
})
}())})
}())});
it('Certify: Expiry', function(done){(async function(){
var alice = await SEA.pair()
@@ -684,6 +683,7 @@ describe('SEA', function(){
.get('today')
.once(_data => {
expect(_data).to.be(data)
user.leave();
done()
})
}, { opt: { cert } })
@@ -691,7 +691,7 @@ describe('SEA', function(){
})
}())})
it('Certify: Advanced - Blacklist', function(done){(async function(){
it.skip('Certify: Advanced - Blacklist', function(done){(async function(){
var alice = await SEA.pair()
var dave = await SEA.pair()
var bob = await SEA.pair()
@@ -699,26 +699,32 @@ describe('SEA', function(){
expiry: Gun.state() + 5000, // expires in 5 seconds
blacklist: 'blacklist' // path to blacklist in Alice's graph
})
console.log(111111);
// Alice points her blacklist to Dave's graph
user.leave()
user.auth(alice, async () => {
await user.get('blacklist').put({'#': '~'+dave.pub+'/blacklist'})
await user.leave()
console.log("meeeeoooooow");
var ref = gun.get('~'+dave.pub+'/blacklist');
await user.get('blacklist').put(ref);
user.leave()
console.log(2222222);
// Dave logins, he adds Bob to his blacklist, which is connected to the certificate that Alice issued for Bob
user.auth(dave, async () => {
await user.get('blacklist').get(bob.pub).put(true)
await user.leave()
user.leave()
console.log(333333);
// Bob logins and tries to hack Alice
user.auth(bob, async () => {
console.log(4444444);
var data = Gun.state().toString(36)
gun.get("~" + alice.pub)
.get("private")
.get("asdf")
.get("qwerty")
.put(data, ack => {
console.log(555555);
expect(ack.err).to.be.ok()
user.leave()
done()
@@ -728,6 +734,13 @@ describe('SEA', function(){
})
}())})
});
describe('node', function(){
var u;
if(''+u === typeof process){ return }
console.log("REMEMBER TO RUN mocha test/sea/nodeauth !!!!");
});
});
})