mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-28 00:46:45 +01:00
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import { EncryptedFields } from '../../src/cdp/encryption-utils'
|
|
import { Hub } from '../../src/types'
|
|
import { insertHogFunction as _insertHogFunction } from './fixtures'
|
|
|
|
describe('Encrypted fields', () => {
|
|
jest.setTimeout(1000)
|
|
let encryptedFields: EncryptedFields
|
|
|
|
const mockHub: Partial<Hub> = {
|
|
ENCRYPTION_SALT_KEYS: '00beef0000beef0000beef0000beef00',
|
|
}
|
|
|
|
beforeEach(() => {
|
|
encryptedFields = new EncryptedFields(mockHub as unknown as Hub)
|
|
})
|
|
|
|
describe('encryption and decryption', () => {
|
|
it('should encrypt and decrypt a string', () => {
|
|
const encrypted = encryptedFields.encrypt('test-case')
|
|
expect(encrypted).not.toEqual('test-case')
|
|
const decrypted = encryptedFields.decrypt(encrypted)
|
|
expect(decrypted).toEqual('test-case')
|
|
})
|
|
|
|
it('should decode django example', () => {
|
|
const encrypted =
|
|
'gAAAAABlkgC8AAAAAAAAAAAAAAAAAAAAAP89mTGU6xUyLcVUIB4ySnX2Y8ZgwLALpzYGfm76Fk64vPRY62flSIigMa_MqTlKyA=='
|
|
const decrypted = encryptedFields.decrypt(encrypted)
|
|
expect(decrypted).toEqual('test-case')
|
|
})
|
|
})
|
|
})
|