storj/web/satellite/tests/unit/mock/api/accessGrants.ts
Vitalii Shpital 6ddcacbe78 web/satellite: initial setup of bucket's view of objects page
WHAT:
setup of objects store module,
setup of initial bucket's view,
generate special API key that will be used to generate gateway credentials

WHY:
initial setup of future bucket's management view

Change-Id: I0078869b95c04c0b142b2e112e93ff2332e8e90f
2021-03-25 09:48:16 +00:00

43 lines
1.3 KiB
TypeScript

// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
import {
AccessGrant,
AccessGrantCursor,
AccessGrantsApi,
AccessGrantsPage,
GatewayCredentials,
} from '@/types/accessGrants';
/**
* Mock for AccessGrantsApi
*/
export class AccessGrantsMock implements AccessGrantsApi {
private readonly date = new Date(0);
private mockAccessGrantsPage: AccessGrantsPage;
public setMockApiKeysPage(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): Promise<GatewayCredentials> {
return Promise.resolve(new GatewayCredentials('testCredId', new Date(), 'testAccessKeyId', 'testSecret', 'testEndpoint'));
}
}