it('covers valid profile', async function () {
ctx.parsedBody.me = 'https://example.com/profile';
manager.indieAuthCommunication.fetchProfile.resolves({
- authorizationEndpoint: 'https://example.com/auth',
+ metadata: {
+ authorizationEndpoint: 'https://example.com/auth',
+ },
});
await manager.postAdminLogin(res, ctx);
assert.strictEqual(res.statusCode, 302);
it('covers invalid profile response endpoint', async function () {
ctx.parsedBody.me = 'https://example.com/profile';
manager.indieAuthCommunication.fetchProfile.resolves({
- authorizationEndpoint: 'not an auth endpoint',
+ metadata: {
+ authorizationEndpoint: 'not an auth endpoint',
+ },
});
await manager.postAdminLogin(res, ctx);
assert(!res.setHeader.called);
});
+ describe('living-standard-20220212', function () {
+ it('covers valid profile', async function () {
+ ctx.parsedBody.me = 'https://example.com/profile';
+ manager.indieAuthCommunication.fetchProfile.resolves({
+ metadata: {
+ issuer: 'https://example.com/',
+ authorizationEndpoint: 'https://example.com/auth',
+ },
+ });
+ await manager.postAdminLogin(res, ctx);
+ assert.strictEqual(res.statusCode, 302);
+ });
+ it('covers bad issuer url', async function () {
+ ctx.parsedBody.me = 'https://example.com/profile';
+ manager.indieAuthCommunication.fetchProfile.resolves({
+ metadata: {
+ issuer: 'http://example.com/?bah#foo',
+ authorizationEndpoint: 'https://example.com/auth',
+ },
+ });
+ await manager.postAdminLogin(res, ctx);
+ assert(!res.setHeader.called);
+ });
+ it('covers unparsable issuer url', async function () {
+ ctx.parsedBody.me = 'https://example.com/profile';
+ manager.indieAuthCommunication.fetchProfile.resolves({
+ metadata: {
+ issuer: 'not a url',
+ authorizationEndpoint: 'https://example.com/auth',
+ },
+ });
+ await manager.postAdminLogin(res, ctx);
+ assert(!res.setHeader.called);
+ });
+ }); // living-standard-20220212
}); // postAdminLogin
describe('getAdminLogout', function () {
me,
});
manager.indieAuthCommunication.fetchProfile.resolves({
- authorizationEndpoint,
+ metadata: {
+ authorizationEndpoint,
+ },
});
sinon.stub(manager.mysteryBox, 'unpack').resolves({
authorizationEndpoint,
});
manager.indieAuthCommunication.fetchProfile.restore();
sinon.stub(manager.indieAuthCommunication, 'fetchProfile').resolves({
- authorizationEndpoint: 'https://elsewhere.example.com/auth',
+ metadata: {
+ authorizationEndpoint: 'https://elsewhere.example.com/auth',
+ },
});
await manager.getAdminIA(res, ctx);
assert(ctx.errors.length);
});
+ describe('living-standard-20220212', function () {
+ beforeEach(function () {
+ manager.indieAuthCommunication.fetchProfile.resolves({
+ metadata: {
+ authorizationEndpoint,
+ issuer: 'https://example.com/',
+ },
+ });
+ manager.mysteryBox.unpack.resolves({
+ authorizationEndpoint,
+ issuer: 'https://example.com/',
+ state,
+ me,
+ });
+ });
+ it('covers valid', async function () {
+ ctx.queryParams['state'] = state;
+ ctx.queryParams['code'] = 'codeCodeCode';
+ ctx.queryParams['iss'] = 'https://example.com/';
+
+ await manager.getAdminIA(res, ctx);
+
+ assert.strictEqual(res.statusCode, 302);
+ });
+ it('covers mis-matched issuer', async function () {
+ ctx.queryParams['state'] = state;
+ ctx.queryParams['code'] = 'codeCodeCode';
+
+ await manager.getAdminIA(res, ctx);
+
+ assert(ctx.errors.length);
+ });
+ }); // living-standard-20220212
}); // getAdminIA
}); // SessionManager
\ No newline at end of file