storj/web/satellite/tests/unit/mock/api/accessGrants.ts
Vitalii Shpital 3c8e41e665 web/satellite: get object map and preview by signed request.
There is a sev-2 issue to add more browser caching.
In this PR I made object map and object preview to be fetched by signed request with non-public credentials using AWS SignatureV4 package.

Change-Id: Ib5013fa6d6af3faa97eed5168c11a13f9629cd87
2022-02-03 11:31:09 +00:00

43 lines
1.3 KiB
TypeScript

// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
import {
AccessGrant,
AccessGrantCursor,
AccessGrantsApi,
AccessGrantsPage,
EdgeCredentials,
} from '@/types/accessGrants';
/**
* Mock for AccessGrantsApi
*/
export class AccessGrantsMock implements AccessGrantsApi {
private readonly date = new Date(0);
private mockAccessGrantsPage: AccessGrantsPage;
public setMockAccessGrantsPage(mockAccessGrantsPage: AccessGrantsPage): void {
this.mockAccessGrantsPage = mockAccessGrantsPage;
}
get(_projectId: string, _cursor: AccessGrantCursor): Promise<AccessGrantsPage> {
return Promise.resolve(this.mockAccessGrantsPage);
}
create(_projectId: string, _name: string): Promise<AccessGrant> {
return Promise.resolve(new AccessGrant('testId', 'testName', this.date, 'testKey'));
}
delete(_ids: string[]): Promise<void> {
return Promise.resolve();
}
deleteByNameAndProjectID(_name: string, _projectID: string): Promise<void> {
return Promise.resolve();
}
getGatewayCredentials(_accessGrant: string, _optionalURL?: string): Promise<EdgeCredentials> {
return Promise.resolve(new EdgeCredentials('testCredId', new Date(), 'testAccessKeyId', 'testSecret', 'testEndpoint'));
}
}