b05f6b9da0
Jenkins Production Deployment
Co-authored-by: Patrick Müller <mail@pmueller.me> Reviewed-on: #7 Co-authored-by: Patrick Mueller <patrick@mueller-patrick.tech> Co-committed-by: Patrick Mueller <patrick@mueller-patrick.tech>
21 lines
581 B
TypeScript
21 lines
581 B
TypeScript
import {hashIp} from '../../src/models/feedback/feedback.ratelimit';
|
|
|
|
describe('hashIp', () => {
|
|
it('never returns the raw IP', () => {
|
|
const hash = hashIp('203.0.113.42');
|
|
expect(hash).not.toContain('203.0.113.42');
|
|
});
|
|
|
|
it('is deterministic for the same input', () => {
|
|
expect(hashIp('203.0.113.42')).toBe(hashIp('203.0.113.42'));
|
|
});
|
|
|
|
it('differs for different inputs', () => {
|
|
expect(hashIp('203.0.113.42')).not.toBe(hashIp('203.0.113.43'));
|
|
});
|
|
|
|
it('is a 64-char hex SHA-256 digest', () => {
|
|
expect(hashIp('203.0.113.42')).toMatch(/^[0-9a-f]{64}$/);
|
|
});
|
|
});
|