import Crypto from 'crypto-js';

describe('upyun access token', () => {
    test('calculate access token', () => {
        const secret = "C29DBA1F1EA4462088136C3A85C2FBFC";
        // const etime = Math.ceil(Date.now() / 1000) + 3600; // 1小时有效
        let etime = 1657886416;
        const uri = '/music-room/17c832cb-bc6b-41f7-96cd-190b7fe4a3d7.jpeg';
        const sign = Crypto.MD5(`${secret}&${etime}&${uri}`).toString();
        let upt = sign.substring(12, 12 + 8) + etime;
        console.log(sign, upt, etime)
        expect(sign).toBe('48d172b8b96b84f91d806a7beee421f1')
        expect(upt).toBe('84f91d801657886416')
    })
})
