diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 09:45:46 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 09:45:46 +0000 |
commit | a7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch) | |
tree | 7452bd5c3545c2fa67a28aa013835fb4fa071baf /spec/frontend/authentication/webauthn | |
parent | ee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff) | |
download | gitlab-ce-a7b3560714b4d9cc4ab32dffcd1f74a284b93580.tar.gz |
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'spec/frontend/authentication/webauthn')
-rw-r--r-- | spec/frontend/authentication/webauthn/util_spec.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/frontend/authentication/webauthn/util_spec.js b/spec/frontend/authentication/webauthn/util_spec.js new file mode 100644 index 00000000000..c9b8bfd8679 --- /dev/null +++ b/spec/frontend/authentication/webauthn/util_spec.js @@ -0,0 +1,19 @@ +import { base64ToBuffer, bufferToBase64 } from '~/authentication/webauthn/util'; + +const encodedString = 'SGVsbG8gd29ybGQh'; +const stringBytes = [72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33]; + +describe('Webauthn utils', () => { + it('base64ToBuffer', () => { + const toArray = (val) => new Uint8Array(val); + + expect(base64ToBuffer(encodedString)).toBeInstanceOf(ArrayBuffer); + + expect(toArray(base64ToBuffer(encodedString))).toEqual(toArray(stringBytes)); + }); + + it('bufferToBase64', () => { + const buffer = base64ToBuffer(encodedString); + expect(bufferToBase64(buffer)).toBe(encodedString); + }); +}); |