Skip to content

Commit

Permalink
update store test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymek committed Jul 10, 2024
1 parent 17c8e7e commit 09f6f83
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/__snapshots__/create-config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ exports[`should create default config 1`] = `
"flagResolver": FlagResolver {
"experiments": {
"adminTokenKillSwitch": false,
"allowOrphanedWildcardTokens": false,
"allowOrphanedWildcardTokens": true,
"anonymiseEventLog": false,
"anonymizeProjectOwners": false,
"automatedActions": false,
Expand Down
35 changes: 34 additions & 1 deletion src/test/e2e/stores/api-token-store.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,40 @@ test('get token returns the token when exists', async () => {
});

describe('count deprecated tokens', () => {
test('should return 0 for all deprecated tokens', async () => {
test('should return 0 if there is no legacy or orphaned tokens', async () => {
await stores.projectStore.create({
id: 'test',
name: 'test',
});
await stores.apiTokenStore.insert({
secret: '*:*.be44368985f7fb3237c584ef86f3d6bdada42ddbd63a019d26955178',
environment: 'default',
type: ApiTokenType.ADMIN,
projects: [],
tokenName: 'admin-token',
});
await stores.apiTokenStore.insert({
secret: 'default:development.be44368985f7fb3237c584ef86f3d6bdada42ddbd63a019d26955178',
environment: 'default',
type: ApiTokenType.CLIENT,
projects: ['default'],
tokenName: 'client-token',
});
await stores.apiTokenStore.insert({
secret: '*:development.be44368985f7fb3237c584ef86f3d6bdada42ddbd63a019d26955178',
environment: 'default',
type: ApiTokenType.CLIENT,
projects: [],
tokenName: 'client-wildcard-token',
});
await stores.apiTokenStore.insert({
secret: '[]:production.3d6bdada42ddbd63a019d26955178be44368985f7fb3237c584ef86f',
environment: 'default',
type: ApiTokenType.FRONTEND,
projects: ['default', 'test'],
tokenName: 'frontend-token',
});

const deprecatedTokens =
await stores.apiTokenStore.countDeprecatedTokens();

Expand Down

0 comments on commit 09f6f83

Please sign in to comment.