mirror of
https://github.com/SomboChea/ui
synced 2026-01-19 09:36:30 +07:00
committed by
Ayush Sharma
parent
1070e5c3aa
commit
9d7be476ad
26
test/unit/components/__mocks__/token.js
Normal file
26
test/unit/components/__mocks__/token.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Token Utility
|
||||
*/
|
||||
|
||||
import { Base64 } from 'js-base64';
|
||||
import addHours from 'date-fns/add_hours';
|
||||
|
||||
export function generateTokenWithTimeRange (limit = 0) {
|
||||
const payload = {
|
||||
username: 'verdaccio',
|
||||
exp: Number.parseInt(addHours(new Date(), limit).getTime() / 1000, 10)
|
||||
};
|
||||
return `xxxxxx.${Base64.encode(JSON.stringify(payload))}.xxxxxx`;
|
||||
}
|
||||
|
||||
export function generateTokenWithExpirationAsString () {
|
||||
const payload = { username: 'verdaccio', exp: 'I am not a number' };
|
||||
return `xxxxxx.${Base64.encode(payload)}.xxxxxx`;
|
||||
}
|
||||
|
||||
export function generateTokenWithOutExpiration (){
|
||||
const payload = {
|
||||
username: 'verdaccio'
|
||||
};
|
||||
return `xxxxxx.${Base64.encode(JSON.stringify(payload))}.xxxxxx`;
|
||||
}
|
||||
Reference in New Issue
Block a user