refactor: 💡 deauth should delete the auth token (#1256)

This commit is contained in:
Randall Morey authored and GitHub committed 2022-08-15 11:22:27 -07:00
1 parent e3324ad64a
commit 7386b2c9ed
4 files changed
+15 -10

No files matched your search

@@ -10,22 +10,24 @@ module('Unit | Authenticator | base', function (hooks) {
test('it deauthenticates on invalidation', async function (assert) {
assert.expect(1);
const authenticator = this.owner.lookup('authenticator:base');
this.server.post(authenticator.buildDeauthEndpointURL(), () => {
const endpoint = authenticator.buildDeauthEndpointURL({ id: 'token123' });
this.server.delete(endpoint, () => {
assert.ok(true, 'deauthentication occurred');
return new Response(200);
});
await authenticator.invalidate();
await authenticator.invalidate({ token: 'token123' });
});
test('invalidation succeeds even if the deauthentication request fails', async function (assert) {
assert.expect(2);
const authenticator = this.owner.lookup('authenticator:base');
this.server.post(authenticator.buildDeauthEndpointURL(), () => {
const endpoint = authenticator.buildDeauthEndpointURL({ id: 'token123' });
this.server.delete(endpoint, () => {
assert.ok(true, 'deauthentication was requested');
return new Response(500);
});
await authenticator
.invalidate()
.invalidate({ token: 'token123' })
.then(() => assert.ok(true))
.catch(() => assert.notOk(true, 'uh oh, this should not happen'));
});