This commit is contained in:
rijkvanzanten
2020-10-27 16:58:14 +01:00
parent 9d9d04557f
commit acfe1c7fb5
3 changed files with 37 additions and 3 deletions

View File

@@ -89,9 +89,10 @@ Research private class property used in extended class.
- [x] Update
- [x] Delete
- [x] Invite
- [ ] Accept Invite
- [ ] Enable TFA
- [ ] Disable TFA
- [x] Accept Invite
- [x] Enable TFA
- [x] Disable TFA
- [ ] Me
- [x] Utils
- [x] Get random string
- [x] Hash a value

View File

@@ -13,4 +13,13 @@ export class UsersHandler extends ItemsHandler {
async acceptInvite(token: string, password: string) {
await this.axios.post('/users/invite/accept', { token, password });
}
tfa = {
enable: async (password: string) => {
await this.axios.post('/users/tfa/enable', { password });
},
disable: async (otp: string) => {
await this.axios.post('/users/tfa/disable', { otp });
},
};
}

View File

@@ -55,4 +55,28 @@ describe('UsersHandler', () => {
});
});
});
describe('tfa.enable', () => {
it('Calls the /users/tfa/enable endpoint', async () => {
const stub = sandbox.stub(handler.axios, 'post').resolves(Promise.resolve());
await handler.tfa.enable('p455w0rd');
expect(stub).to.have.been.calledWith('/users/tfa/enable', {
password: 'p455w0rd',
});
});
});
describe('tfa.disable', () => {
it('Calls the /users/tfa/disable endpoint', async () => {
const stub = sandbox.stub(handler.axios, 'post').resolves(Promise.resolve());
await handler.tfa.disable('351851');
expect(stub).to.have.been.calledWith('/users/tfa/disable', {
otp: '351851',
});
});
});
});