Skip to content

Commit

Permalink
add one test for user matching by id with account linking
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Kgaevski committed Mar 31, 2017
1 parent 69dbe02 commit 1703e63
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/client-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@ describe("Hull", () => {
.that.eql({ email: "foo@bar.com" });
});

it("should allow to link a user using its id to an account", () => {
const hull = new Hull({ id: "562123b470df84b740000042", secret: "1234", organization: "test" });

const scoped = hull.asUser("1234").account({ domain: "hull.io" });
const scopedJwtClaims = jwt.decode(scoped.configuration().accessToken, scoped.configuration().secret);

expect(scopedJwtClaims)
.to.have.property("io.hull.subjectType")
.that.eql("account");
expect(scopedJwtClaims)
.to.have.property("io.hull.asAccount")
.that.eql({ domain: "hull.io" });
expect(scopedJwtClaims)
.to.have.property("io.hull.asUser")
.that.eql({ id: "1234" });
});

it("should allow to resolve an existing account user is linked to", () => {
const hull = new Hull({ id: "562123b470df84b740000042", secret: "1234", organization: "test" });

Expand Down Expand Up @@ -126,6 +143,6 @@ describe("Hull", () => {
.to.not.throw(Error);
expect(hull.asAccount.bind(null, { external_id: "1234" }))
.to.not.throw(Error);
})
});
});
});

0 comments on commit 1703e63

Please sign in to comment.