-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15865e5
commit 9fd534d
Showing
3 changed files
with
157 additions
and
2 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ import * as chaiAsPromised from 'chai-as-promised'; | |
|
||
import { deepCopy } from '../../../src/utils/deep-copy'; | ||
import { | ||
GetAccountInfoUserResponse, ProviderUserInfoResponse, MultiFactorInfoResponse, TotpMultiFactorInfo, | ||
GetAccountInfoUserResponse, ProviderUserInfoResponse, MultiFactorInfoResponse, TotpMultiFactorInfo, PasskeyInfo, | ||
} from '../../../src/auth/user-record'; | ||
import { | ||
UserInfo, UserMetadata, UserRecord, MultiFactorSettings, MultiFactorInfo, PhoneMultiFactorInfo, | ||
|
@@ -100,6 +100,18 @@ function getValidUserResponse(tenantId?: string): GetAccountInfoUserResponse { | |
phoneInfo: '+16505556789', | ||
}, | ||
], | ||
passkeyInfo: [ | ||
{ | ||
name: "[email protected]", | ||
credentialId: "credentialId1", | ||
displayName: "passkey1", | ||
}, | ||
{ | ||
name: "[email protected]", | ||
credentialId: "credentialId2", | ||
displayName: "passkey2", | ||
} | ||
] | ||
}; | ||
if (typeof tenantId !== 'undefined') { | ||
response.tenantId = tenantId; | ||
|
@@ -185,6 +197,18 @@ function getUserJSON(tenantId?: string): object { | |
}, | ||
], | ||
}, | ||
passkeyInfo: [ | ||
{ | ||
name: "[email protected]", | ||
credentialId: "credentialId1", | ||
displayName: "passkey1", | ||
}, | ||
{ | ||
name: "[email protected]", | ||
credentialId: "credentialId2", | ||
displayName: "passkey2", | ||
} | ||
] | ||
}; | ||
} | ||
|
||
|
@@ -663,6 +687,66 @@ describe('MultiFactorSettings', () => { | |
}); | ||
}); | ||
|
||
describe('PasskeyInfo', () => { | ||
const passkeyInfoData = { | ||
name: 'John Doe', | ||
credentialId: 'credential123', | ||
displayName: '[email protected]', | ||
}; | ||
const passkeyInfo = new PasskeyInfo(passkeyInfoData); | ||
|
||
describe('constructor', () => { | ||
it('should create a PasskeyInfo object with valid data', () => { | ||
expect(passkeyInfo).to.be.an.instanceOf(PasskeyInfo); | ||
}); | ||
|
||
it('should throw when missing required fields', () => { | ||
expect(() => { | ||
return new PasskeyInfo({}); | ||
}).to.throw('INTERNAL ASSERT FAILED: Invalid passkey info response'); | ||
}); | ||
}); | ||
|
||
describe('getters', () => { | ||
it('should return the expected name', () => { | ||
expect(passkeyInfo.name).to.equal(passkeyInfoData.name); | ||
}); | ||
|
||
it('should throw when modifying readonly name property', () => { | ||
expect(() => { | ||
(passkeyInfo as any).name = 'Modified Name'; | ||
}).to.throw(Error); | ||
}); | ||
|
||
it('should return the expected credentialId', () => { | ||
expect(passkeyInfo.credentialId).to.equal(passkeyInfoData.credentialId); | ||
}); | ||
|
||
it('should throw when modifying readonly credentialId property', () => { | ||
expect(() => { | ||
(passkeyInfo as any).credentialId = 'modifiedCredential'; | ||
}).to.throw(Error); | ||
}); | ||
|
||
it('should return the expected displayName', () => { | ||
expect(passkeyInfo.displayName).to.equal(passkeyInfoData.displayName); | ||
}); | ||
|
||
it('should throw when modifying readonly displayName property', () => { | ||
expect(() => { | ||
(passkeyInfo as any).displayName = 'modifiedDisplayName'; | ||
}).to.throw(Error); | ||
}); | ||
}); | ||
|
||
describe('toJSON', () => { | ||
it('should return the expected JSON object', () => { | ||
expect(passkeyInfo.toJSON()).to.deep.equal(passkeyInfoData); | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
describe('UserInfo', () => { | ||
describe('constructor', () => { | ||
it('should throw when an empty object is provided', () => { | ||
|