add unverified URL data test case
This commit is contained in:
parent
67b12fceb0
commit
60413bf39b
|
@ -1,19 +1,18 @@
|
||||||
import { describe, expect, test } from 'vitest'
|
import { expect, test } from 'vitest'
|
||||||
|
|
||||||
import { signEncodedURLData, verifyEncodedURLData } from './sign-url-data'
|
import { signEncodedURLData, verifyEncodedURLData } from './sign-url-data'
|
||||||
|
|
||||||
import type { EncodedURLData } from './encode-url-data'
|
import type { EncodedURLData } from './encode-url-data'
|
||||||
|
|
||||||
describe('Sign URL data', () => {
|
|
||||||
const privateKey = new Uint8Array([
|
const privateKey = new Uint8Array([
|
||||||
233, 34, 68, 49, 2, 175, 16, 66, 41, 112, 38, 154, 139, 197, 117, 203, 223,
|
233, 34, 68, 49, 2, 175, 16, 66, 41, 112, 38, 154, 139, 197, 117, 203, 223,
|
||||||
215, 4, 135, 228, 217, 5, 31, 75, 9, 30, 221, 141, 239, 82, 84,
|
215, 4, 135, 228, 217, 5, 31, 75, 9, 30, 221, 141, 239, 82, 84,
|
||||||
])
|
])
|
||||||
|
|
||||||
test('should sign and verify URL data', async () => {
|
|
||||||
const encodedURLData =
|
const encodedURLData =
|
||||||
'G74AgK0ObFNmYT-WC_Jcc9KfSjHXAQo9THKEEbgPaJoItceMES-bUxr2Tj9efv447rRefBIUg9CEsSFyjBOFTRdZ9PH2wUOW8hVNYqIje3BC96mZ8uFogqM6k7gCCJnMHy4ulsmsgHTdeh5dAzTNNuG8m9XB8oVeildTCKlRhINnTZh4kAl5sP8SzBB4V2_I41a8PKl3mcS0z_eF5gA=' as EncodedURLData
|
'G74AgK0ObFNmYT-WC_Jcc9KfSjHXAQo9THKEEbgPaJoItceMES-bUxr2Tj9efv447rRefBIUg9CEsSFyjBOFTRdZ9PH2wUOW8hVNYqIje3BC96mZ8uFogqM6k7gCCJnMHy4ulsmsgHTdeh5dAzTNNuG8m9XB8oVeildTCKlRhINnTZh4kAl5sP8SzBB4V2_I41a8PKl3mcS0z_eF5gA=' as EncodedURLData
|
||||||
|
|
||||||
|
test('should sign and verify URL data', async () => {
|
||||||
const signature = await signEncodedURLData(encodedURLData, privateKey)
|
const signature = await signEncodedURLData(encodedURLData, privateKey)
|
||||||
|
|
||||||
expect(signature).toBe(
|
expect(signature).toBe(
|
||||||
|
@ -21,4 +20,12 @@ describe('Sign URL data', () => {
|
||||||
)
|
)
|
||||||
expect(verifyEncodedURLData(signature, encodedURLData)).toBe(true)
|
expect(verifyEncodedURLData(signature, encodedURLData)).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test.todo('should not verify URL data', async () => {
|
||||||
|
const signatureForAnotherContent =
|
||||||
|
'OyOgY6Zta8S7U4l5Bv_9E_7snALhixwvjxORVAVJ-YJk-tMSGgstOy5XEEQx25TQJIAtpWf8eHnEmV8V-GmouQA='
|
||||||
|
|
||||||
|
expect(verifyEncodedURLData(signatureForAnotherContent, encodedURLData)).toBe(
|
||||||
|
false
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue