-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(secret): link serviceaccount (#950)
* fix(secrets): link unlink secrets to service accounts * fix(secrets): service account test
- Loading branch information
1 parent
668de24
commit f898233
Showing
6 changed files
with
172 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import '@testing-library/jest-dom'; | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import { SecretType } from '../../../types'; | ||
import { useAccessReviewForModel } from '../../../utils/rbac'; | ||
import { useSecretActions } from '../secret-actions'; | ||
|
||
jest.mock('../../../utils/rbac', () => ({ | ||
useAccessReviewForModel: jest.fn(() => [true, true]), | ||
})); | ||
|
||
jest.mock('../../modal/ModalProvider', () => ({ | ||
useModalLauncher: jest.fn(() => 'cta'), | ||
})); | ||
|
||
const useAccessReviewForModelMock = useAccessReviewForModel as jest.Mock; | ||
|
||
describe('useSecretActions', () => { | ||
beforeEach(() => { | ||
useAccessReviewForModelMock.mockReturnValue([true, true]); | ||
}); | ||
|
||
it('should contain trigger actions', async () => { | ||
const { result } = renderHook(() => | ||
useSecretActions({ | ||
metadata: { name: 'test-secret' }, | ||
type: SecretType.opaque, | ||
} as any), | ||
); | ||
const actions = result.current; | ||
|
||
expect(actions[0]).toEqual( | ||
expect.objectContaining({ | ||
label: 'Delete', | ||
disabledTooltip: "You don't have access to delete this secret", | ||
id: 'delete-test-secret', | ||
disabled: false, | ||
}), | ||
); | ||
}); | ||
}); |
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