-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ab/always_attach' into 'master'
fix: Add new error IdentityAlreadyAttached See merge request TankerHQ/sdk-react-native!37
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,11 @@ import { | |
getVerificationCode, | ||
toggleSessionCertificates, | ||
} from './admin'; | ||
import { InvalidArgument, InvalidVerification } from '@tanker/errors'; | ||
import { | ||
InvalidArgument, | ||
InvalidVerification, | ||
IdentityAlreadyAttached, | ||
} from '@tanker/errors'; | ||
import { createTanker, clearTankerDataDirs } from './tests'; | ||
import base64 from 'react-native-base64'; | ||
|
||
|
@@ -212,6 +216,33 @@ export const tankerTests = () => { | |
await tanker.verifyProvisionalIdentity({ email, verificationCode }); | ||
}); | ||
|
||
it('throws when attaching an already attached provisional identity', async () => { | ||
await tanker.start(identity); | ||
await tanker.registerIdentity({ | ||
passphrase: 'ice cold water', | ||
}); | ||
const email = '[email protected]'; | ||
const provIdentity = await createProvisionalIdentity(email); | ||
const result = await tanker.attachProvisionalIdentity(provIdentity); | ||
expect(result.verificationMethod).deep.eq({ type: 'email', email }); | ||
|
||
const verificationCode = await getVerificationCode(email); | ||
await tanker.verifyProvisionalIdentity({ email, verificationCode }); | ||
|
||
const other = await createTanker(); | ||
await other.start(await createIdentity()); | ||
await other.registerIdentity({ passphrase: 'otherpass' }); | ||
other.attachProvisionalIdentity(provIdentity); | ||
expect(result.status).eq(Tanker.statuses.IDENTITY_VERIFICATION_NEEDED); | ||
const verificationCode2 = await getVerificationCode(email); | ||
await expect( | ||
other.verifyProvisionalIdentity({ | ||
email, | ||
verificationCode: verificationCode2, | ||
}) | ||
).to.be.rejectedWith(IdentityAlreadyAttached); | ||
}); | ||
|
||
it('can skip provisional identity verification', async () => { | ||
const email = '[email protected]'; | ||
const provIdentity = await createProvisionalIdentity(email); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters