forked from rancher/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rancher#11431 from torchiaf/10725-ca-bundle-key-2
Fix CA Bundle format
- Loading branch information
Showing
2 changed files
with
69 additions
and
2 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
61 changes: 61 additions & 0 deletions
61
shell/edit/provisioning.cattle.io.cluster/tabs/registries/__tests__/RegistryConfigs.test.ts
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,61 @@ | ||
import { mount, Wrapper } from '@vue/test-utils'; | ||
import { clone } from '@shell/utils/object'; | ||
import { _EDIT } from '@shell/config/query-params'; | ||
import { PROV_CLUSTER } from '@shell/edit/provisioning.cattle.io.cluster/__tests__/utils/cluster'; | ||
import RegistryConfigs from '@shell/edit/provisioning.cattle.io.cluster/tabs/registries/RegistryConfigs.vue'; | ||
|
||
describe('component: RegistryConfigs', () => { | ||
let wrapper: Wrapper<InstanceType<typeof RegistryConfigs> & { [key: string]: any }>; | ||
|
||
const mountOptions = { | ||
propsData: { | ||
value: {}, | ||
mode: _EDIT, | ||
clusterRegisterBeforeHook: () => {} | ||
}, | ||
stubs: { | ||
SelectOrCreateAuthSecret: true, | ||
SecretSelector: true, | ||
}, | ||
mocks: { $store: { getters: { 'i18n/t': jest.fn() } } } | ||
}; | ||
|
||
describe('key CA Cert Bundle', () => { | ||
it('should display default key', () => { | ||
const value = clone(PROV_CLUSTER); | ||
|
||
value.spec.rkeConfig.registries.configs = { foo: { caBundle: 'Zm9vYmFy' } }; | ||
|
||
mountOptions.propsData.value = value; | ||
|
||
wrapper = mount( | ||
RegistryConfigs, | ||
mountOptions | ||
); | ||
|
||
const registry = wrapper.find('[data-testid^="registry-caBundle"]').element as HTMLTextAreaElement; | ||
|
||
expect(registry.value).toBe('foobar'); | ||
}); | ||
|
||
it('should update key in base64 format', async() => { | ||
const value = clone(PROV_CLUSTER); | ||
|
||
value.spec.rkeConfig.registries.configs = { foo: { caBundle: 'Zm9vYmFy' } }; | ||
|
||
mountOptions.propsData.value = value; | ||
|
||
wrapper = mount( | ||
RegistryConfigs, | ||
mountOptions | ||
); | ||
|
||
const registry = wrapper.find('[data-testid^="registry-caBundle"]'); | ||
|
||
await registry.setValue('ssh key'); | ||
wrapper.vm.update(); | ||
|
||
expect(wrapper.emitted('updateConfigs')![0][0]['foo']['caBundle']).toBe('c3NoIGtleQ=='); | ||
}); | ||
}); | ||
}); |