Skip to content

Commit d93353c

Browse files
committed
test: added tests for createHmacSignature()
1 parent 29a048e commit d93353c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/hmac.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { createHmacSignature } from '@apify/utilities';
2+
3+
describe('createHmacSignature()', () => {
4+
it('should create a valid HMAC signature', () => {
5+
const secretKey = 'hmac-secret-key';
6+
const message = 'hmac-message-to-be-authenticated';
7+
expect(createHmacSignature(secretKey, message)).toBe('pcVagAsud2gqKY2qCy2G');
8+
});
9+
10+
it('should create same HMAC signature, when secretKey and message are same', () => {
11+
const secretKey = 'hmac-same-secret-key';
12+
const message = 'hmac-same-message-to-be-authenticated';
13+
for (let i = 0; i < 5; i++) {
14+
expect(createHmacSignature(secretKey, message)).toBe('FYMcmTIm2sQ68EcG8yyQ');
15+
}
16+
});
17+
});

0 commit comments

Comments
 (0)