Deprecate dummy enterprise key 1/2 (#20890)
Remove usage of hasValidEnterpriseKey in FE (replaced by hasValidSignedEnterpriseKey) To avoid breaking change at deploy time, we will wait until after this has been deployed in prod, to remove hasValidEnterpriseKey in the BE.
This commit is contained in:
-25
@@ -286,31 +286,6 @@ describe('EnterprisePlanService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// hasValidEnterpriseKey now means "has any ENTERPRISE_KEY configured"
|
||||
describe('hasValidEnterpriseKey', () => {
|
||||
it('should return true when signed enterprise key is valid', async () => {
|
||||
await setupValidState();
|
||||
|
||||
expect(service.hasValidEnterpriseKey()).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true with unsigned legacy key', async () => {
|
||||
setupEnterpriseKey('some-legacy-key');
|
||||
mockCryptoVerify.mockReturnValue(false);
|
||||
appTokenFindOneMock.mockResolvedValue(null);
|
||||
await service.onModuleInit();
|
||||
|
||||
expect(service.hasValidEnterpriseKey()).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false when no key is configured', async () => {
|
||||
setupEnterpriseKey(undefined);
|
||||
await service.onModuleInit();
|
||||
|
||||
expect(service.hasValidEnterpriseKey()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isValid', () => {
|
||||
it('should return true when validity token is valid', async () => {
|
||||
await setupValidState();
|
||||
|
||||
-9
@@ -142,19 +142,10 @@ export class EnterprisePlanService implements OnModuleInit {
|
||||
return false;
|
||||
}
|
||||
|
||||
hasValidEnterpriseKey(): boolean {
|
||||
return this.hasValidSignedEnterpriseKey() || this.checkLegacyKey();
|
||||
}
|
||||
|
||||
isValid(): boolean {
|
||||
return this.hasValidEnterpriseValidityToken();
|
||||
}
|
||||
|
||||
private checkLegacyKey(): boolean {
|
||||
// temporary
|
||||
return isDefined(this.twentyConfigService.get('ENTERPRISE_KEY'));
|
||||
}
|
||||
|
||||
isValidEnterpriseKeyFormat(key: string): boolean {
|
||||
return this.verifyJwt<EnterpriseKeyPayload>(key) !== null;
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ export class WorkspaceResolver {
|
||||
|
||||
@ResolveField(() => Boolean)
|
||||
hasValidEnterpriseKey(): boolean {
|
||||
return this.enterprisePlanService.hasValidEnterpriseKey();
|
||||
return this.enterprisePlanService.hasValidSignedEnterpriseKey();
|
||||
}
|
||||
|
||||
@ResolveField(() => Boolean)
|
||||
|
||||
Reference in New Issue
Block a user