mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
c60bca777f
As #4475 says, MD5 is not available in secure places anymore. This PR swaps out gravatar-url with an inline function using crypto:sha256 which is FIPS-140-2 compliant. Since we only used this method for generating avatar URLs the extra customization wasn't needed and we could hard code the URL parameters. fixes: Linear https://linear.app/unleash/issue/SR-112/gh-support-swap-out-gravatar-url-lib closes: #4475
22 lines
1007 B
TypeScript
22 lines
1007 B
TypeScript
import { generateImageUrl } from './generateImageUrl';
|
|
|
|
describe('Gravatar image url', () => {
|
|
it('generates the correct sha-256 hash for gravatars test idents', () => {
|
|
expect(generateImageUrl({ email: 'MyEmailAddress@example.com' })).toBe(
|
|
'https://gravatar.com/avatar/84059b07d4be67b806386c0aad8070a23f18836bbaae342275dc0a83414c32ee?s=42&d=retro&r=g',
|
|
);
|
|
});
|
|
it('lowercases and trims all emails', () => {
|
|
const upperCaseAndLeadingSpace = ' helloWorld@example.com';
|
|
const upperCaseAndTrailingSpace = 'helloWorld@exAMPLE.com ';
|
|
const lowerCaseAndNoSpaces = 'helloworld@example.com';
|
|
const uCALSHash = generateImageUrl({ email: upperCaseAndLeadingSpace });
|
|
const uCATSHash = generateImageUrl({
|
|
email: upperCaseAndTrailingSpace,
|
|
});
|
|
const lCANSHash = generateImageUrl({ email: lowerCaseAndNoSpaces });
|
|
expect(uCALSHash).toBe(uCATSHash);
|
|
expect(uCATSHash).toBe(lCANSHash);
|
|
});
|
|
});
|