* @property {(DBContextExec) => Promise<any>} context
* @property {(dbCtx: any, identifier: String) => Promise<AuthInfo> } authenticationGet
* @property {(dbCtx: any, identifier: String) => Promise<void>} authenticationSuccess
- * @property {(dbCtx: any, identifier: String, credential: String, otpKey: String=) => Promise<void>} authenticationInsertIdentifier
+ * @property {(dbCtx: any, identifier: String, credential: String, otpKey: String=) => Promise<void>} authenticationUpsert
* @property {(dbCtx: any, identifier: String, otpKey: String) => Promise<void>} authenticationUpdateOTPKey
* @property {(dbCtx: any, identifier: String, credential: AuthInfo) => Promise<void>} authenticationUpdateCredential
*/
const _scope = _fileScope('createIdentifier');
try {
const secureCredential = await this._secureCredential(credential);
- await this.db.authenticationInsertIdentifier(dbCtx, identifier, secureCredential, otpKey);
+ await this.db.authenticationUpsert(dbCtx, identifier, secureCredential, otpKey);
} catch (e) {
this.logger.error(_scope, 'failed', { error: e, identifier });
throw e;
it('covers success', async function () {
const otpKey = '1234567890123456789012';
await authenticator.createIdentifier(dbCtx, identifier, credential, otpKey);
- assert(authenticator.db.authenticationInsertIdentifier.called);
+ assert(authenticator.db.authenticationUpsert.called);
});
it('covers failure', async function () {
const expected = new Error('blah');
- await authenticator.db.authenticationInsertIdentifier.rejects(expected);
+ await authenticator.db.authenticationUpsert.rejects(expected);
// assert.rejects was not happy to handle this for some reason
try {
await authenticator.createIdentifier(dbCtx, identifier, credential);
assert.fail('no expecte exception');
} catch (e) {
assert.deepStrictEqual(e, expected);
- assert(authenticator.db.authenticationInsertIdentifier.called);
+ assert(authenticator.db.authenticationUpsert.called);
assert(authenticator.logger.error.called);
}
});
const stubFns = [
'authenticationGet',
- 'authenticationInsertIdentifier',
+ 'authenticationUpsert',
'authenticationSuccess',
'authenticationUpdateCredential',
'authenticationUpdateOTPKey',