add sign in page
This commit is contained in:
46
scripts/oss-deploy-lib.test.mjs
Normal file
46
scripts/oss-deploy-lib.test.mjs
Normal file
@@ -0,0 +1,46 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import {
|
||||
buildObjectKey,
|
||||
createAuthorizationHeader,
|
||||
getCacheControl,
|
||||
getContentType,
|
||||
normalizeEndpoint,
|
||||
} from './oss-deploy-lib.mjs';
|
||||
|
||||
test('normalizeEndpoint strips scheme and trailing slashes', () => {
|
||||
assert.equal(normalizeEndpoint('https://oss-ap-northeast-1.aliyuncs.com/'), 'oss-ap-northeast-1.aliyuncs.com');
|
||||
});
|
||||
|
||||
test('buildObjectKey joins optional prefix with relative path', () => {
|
||||
assert.equal(buildObjectKey('', 'assets/index.js'), 'assets/index.js');
|
||||
assert.equal(buildObjectKey('portal', 'assets/index.js'), 'portal/assets/index.js');
|
||||
});
|
||||
|
||||
test('getCacheControl keeps index uncached and assets immutable', () => {
|
||||
assert.equal(getCacheControl('index.html'), 'no-cache');
|
||||
assert.equal(getCacheControl('assets/index.js'), 'public,max-age=31536000,immutable');
|
||||
assert.equal(getCacheControl('race/index.html'), 'public,max-age=300');
|
||||
});
|
||||
|
||||
test('getContentType resolves common frontend asset types', () => {
|
||||
assert.equal(getContentType('index.html'), 'text/html; charset=utf-8');
|
||||
assert.equal(getContentType('assets/app.css'), 'text/css; charset=utf-8');
|
||||
assert.equal(getContentType('assets/app.js'), 'text/javascript; charset=utf-8');
|
||||
assert.equal(getContentType('favicon.png'), 'image/png');
|
||||
});
|
||||
|
||||
test('createAuthorizationHeader is stable for a known request', () => {
|
||||
const header = createAuthorizationHeader({
|
||||
method: 'PUT',
|
||||
bucket: 'demo-bucket',
|
||||
objectKey: 'assets/index.js',
|
||||
contentType: 'text/javascript; charset=utf-8',
|
||||
date: 'Tue, 17 Mar 2026 12:00:00 GMT',
|
||||
accessKeyId: 'test-id',
|
||||
accessKeySecret: 'test-secret',
|
||||
});
|
||||
|
||||
assert.equal(header, 'OSS test-id:JgyH7mTiSILGGWsnXJwg4KIBRO4=');
|
||||
});
|
||||
Reference in New Issue
Block a user