Skip to content

Commit

Permalink
Merge branch 'dev-E2EE-2542-remove-api' into 'master'
Browse files Browse the repository at this point in the history
feat(E2EE-2542): Remove Tanker app setting 'enroll_users_enabled'

See merge request TankerHQ/sdk-js!1034
  • Loading branch information
ntalfer committed Dec 2, 2024
2 parents 5e7d150 + 34d435d commit fe17506
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 54 deletions.
75 changes: 25 additions & 50 deletions packages/functional-tests/src/enroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,63 +43,39 @@ export const generateEnrollTests = (args: TestArgs) => {
bobIdentity = await appHelper.generateIdentity();
});

describe('server', () => {
describe('with user enrollment disabled', () => {
it('fails to enroll a user with an email address [QKOWQB]', async () => {
await expect(server.enrollUser(bobIdentity, [emailVerification])).to.be.rejectedWith(errors.PreconditionFailed);
});

it('fails to enroll a user with a phone number [D9OGI5]', async () => {
await expect(server.enrollUser(bobIdentity, [phoneNumberVerification])).to.be.rejectedWith(errors.PreconditionFailed);
});

it('fails to enroll a user with oidc', async () => {
return expect(server.enrollUser(bobIdentity, [oidcVerification])).to.be.rejectedWith(errors.PreconditionFailed);
});

it('fails to enroll a user with both an email address and a phone number [ARRQBH]', async () => {
await expect(server.enrollUser(bobIdentity, [emailVerification, phoneNumberVerification])).to.be.rejectedWith(errors.PreconditionFailed);
});
describe('user not enrolled yet', () => {
it('enrolls a user with an email address [53ZC44]', async () => {
await expect(server.enrollUser(bobIdentity, [emailVerification])).to.be.fulfilled;
});

describe('with user enrollment enabled', () => {
before(async () => {
await appHelper.setEnrollUsersEnabled();
});

it('enrolls a user with an email address [53ZC44]', async () => {
await expect(server.enrollUser(bobIdentity, [emailVerification])).to.be.fulfilled;
});

it('enrolls a user with a phone number [DEJGHP]', async () => {
await expect(server.enrollUser(bobIdentity, [phoneNumberVerification])).to.be.fulfilled;
});
it('enrolls a user with a phone number [DEJGHP]', async () => {
await expect(server.enrollUser(bobIdentity, [phoneNumberVerification])).to.be.fulfilled;
});

it('enrolls a user with an oidc', async () => {
await expect(server.enrollUser(bobIdentity, [oidcVerification])).to.be.fulfilled;
});
it('enrolls a user with an oidc', async () => {
await expect(server.enrollUser(bobIdentity, [oidcVerification])).to.be.fulfilled;
});

it('throws when enrolling a user multiple times [BMANVI]', async () => {
await expect(server.enrollUser(bobIdentity, [emailVerification])).to.be.fulfilled;
await expect(server.enrollUser(bobIdentity, [phoneNumberVerification])).to.be.rejectedWith(errors.Conflict);
});
it('throws when enrolling a user multiple times [BMANVI]', async () => {
await expect(server.enrollUser(bobIdentity, [emailVerification])).to.be.fulfilled;
await expect(server.enrollUser(bobIdentity, [phoneNumberVerification])).to.be.rejectedWith(errors.Conflict);
});

it('throws when enrolling a registered user [02NKOO]', async () => {
const bobLaptop = args.makeTanker();
await bobLaptop.start(bobIdentity);
await bobLaptop.registerIdentity({ passphrase: 'passphrase' });
it('throws when enrolling a registered user [02NKOO]', async () => {
const bobLaptop = args.makeTanker();
await bobLaptop.start(bobIdentity);
await bobLaptop.registerIdentity({ passphrase: 'passphrase' });

await expect(server.enrollUser(bobIdentity, [emailVerification])).to.be.rejectedWith(errors.Conflict);
});
await expect(server.enrollUser(bobIdentity, [emailVerification])).to.be.rejectedWith(errors.Conflict);
});

it('enrolls a user with both an email address and a phone number [FJJCBC]', async () => {
await expect(server.enrollUser(bobIdentity, [emailVerification, phoneNumberVerification])).to.be.fulfilled;
});
it('enrolls a user with both an email address and a phone number [FJJCBC]', async () => {
await expect(server.enrollUser(bobIdentity, [emailVerification, phoneNumberVerification])).to.be.fulfilled;
});

it('stays STOPPED after enrolling a user [ED45GK]', async () => {
await expect(server.enrollUser(bobIdentity, [emailVerification, phoneNumberVerification])).to.be.fulfilled;
expect(server.status).to.equal(statuses.STOPPED);
});
it('stays STOPPED after enrolling a user [ED45GK]', async () => {
await expect(server.enrollUser(bobIdentity, [emailVerification, phoneNumberVerification])).to.be.fulfilled;
expect(server.status).to.equal(statuses.STOPPED);
});
});

Expand All @@ -112,7 +88,6 @@ export const generateEnrollTests = (args: TestArgs) => {
const clearText = 'new enrollment feature';

before(async () => {
await appHelper.setEnrollUsersEnabled();
// Let's say Martine is bob's middle name
bobIdToken = await getGoogleIdToken(oidcSettings.googleAuth.users.martine.refreshToken);
oidcVerification.preverifiedOidcSubject = extractSubject(bobIdToken);
Expand Down
4 changes: 0 additions & 4 deletions packages/functional-tests/src/helpers/AppHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ export class AppHelper {
await this._update({ storage_provider: 'none' });
}

async setEnrollUsersEnabled() {
await this._update({ enroll_users_enabled: true });
}

generateIdentity(userId?: string): Promise<b64string> {
const id = userId || uuid.v4();
return createIdentity(utils.toBase64(this.appId), utils.toBase64(this.appSecret), id);
Expand Down

0 comments on commit fe17506

Please sign in to comment.