-
-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add init api tokens option (#1181)
Adds support for initializing a fresh Unleash instance with predefined API tokens. Co-authored-by: sighphyre <liquidwicked64@gmail.com> Co-authored-by: Juraj Malenica <juraj.malenica@mindsmiths.com> Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
- Loading branch information
1 parent
e814a5f
commit e757c00
Showing
12 changed files
with
265 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ApiTokenService } from './api-token-service'; | ||
import { createTestConfig } from '../../test/config/test-config'; | ||
import { IUnleashConfig } from '../server-impl'; | ||
import { ApiTokenType } from '../types/models/api-token'; | ||
import FakeApiTokenStore from '../../test/fixtures/fake-api-token-store'; | ||
|
||
test('Should init api token', async () => { | ||
const token = { | ||
environment: '*', | ||
project: '*', | ||
secret: '*:*:some-random-string', | ||
type: ApiTokenType.ADMIN, | ||
username: 'admin', | ||
}; | ||
|
||
const config: IUnleashConfig = createTestConfig({ | ||
authentication: { | ||
initApiTokens: [token], | ||
}, | ||
}); | ||
const apiTokenStore = new FakeApiTokenStore(); | ||
const insertCalled = new Promise((resolve) => { | ||
apiTokenStore.on('insert', resolve); | ||
}); | ||
|
||
new ApiTokenService({ apiTokenStore }, config); | ||
|
||
await insertCalled; | ||
|
||
const tokens = await apiTokenStore.getAll(); | ||
|
||
expect(tokens).toHaveLength(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
e757c00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: