refactor: auth method is no longer passed via the payload, but is encoded in the path

This commit is contained in:
Randall Morey committed 2020-07-24 11:29:19 -04:00
1 parent 4ef58a0d6d
commit c5280ca27c
2 files changed
+3 -8

No files matched your search

@@ -51,17 +51,14 @@ export default class PasswordAuthenticator extends BaseAuthenticator {
* @param {object} creds
* @param {string} creds.identification is sent to server as `name`
* @param {string} creds.password
* @param {string} authMethodId ID of the auth method to use
* @param {boolean} requestCookies request cookie tokens (default `true`)
* @return {Promise}
*/
async authenticate(
{ identification: name, password },
authMethodID,
requestCookies = true
) {
const body = JSON.stringify({
auth_method_id: authMethodID,
token_type: requestCookies ? 'cookie' : null,
credentials: { name, password },
});
@@ -15,7 +15,7 @@ module('Unit | Authenticator | password', function (hooks) {
assert.ok(json.token_type, 'Requested token cookies by default');
return new Response(200);
});
await authenticator.authenticate({}, '').then(() => {
await authenticator.authenticate({}).then(() => {
assert.ok(true, 'authentication succeeded');
});
});
@@ -28,7 +28,7 @@ module('Unit | Authenticator | password', function (hooks) {
assert.notOk(json.token_type, 'Did not request tokens cookies');
return new Response(200);
});
await authenticator.authenticate({}, '', false).then(() => {
await authenticator.authenticate({}, false).then(() => {
assert.ok(true, 'authentication succeeded');
});
});
@@ -39,7 +39,6 @@ module('Unit | Authenticator | password', function (hooks) {
this.server.post(authenticator.authEndpoint, (schema, request) => {
const json = JSON.parse(request.requestBody);
assert.deepEqual(json, {
auth_method_id: '123',
token_type: 'cookie',
credentials: {
name: 'foo',
@@ -52,8 +51,7 @@ module('Unit | Authenticator | password', function (hooks) {
identification: 'foo',
password: 'bar',
};
const authMethodID = '123';
await authenticator.authenticate(creds, authMethodID);
await authenticator.authenticate(creds);
});
test('it rejects if the endpoint sends an error status code', async function (assert) {