Skip to content

Commit

Permalink
Merge branch 'master' into 11482-extensions-compatibility-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aalves08 authored Jul 25, 2024
2 parents 185eb01 + 2fb8381 commit 83b08d0
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-upload-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build Dashboard (Release)
on:
push:
tags:
- v2.9.*
- v2.*

jobs:
build-validation:
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/scripts/install-codecov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import # One-time step
curl -Os https://cli.codecov.io/latest/linux/codecov
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM.sig
gpg --verify codecov.SHA256SUM.sig codecov.SHA256SUM

shasum -a 256 -c codecov.SHA256SUM
sudo chmod +x codecov
47 changes: 35 additions & 12 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,39 @@

# - name: Run tests
# uses: ./.github/actions/lint
coverage:
runs-on: ubuntu-latest
needs:
- unit-test
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1

# check-e2e-tags:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 1
# - uses: actions/setup-node@v3
# with:
# node-version: '16.x'
# - name: Check e2e tags
# run: |
# ./scripts/check-e2e-tests-for-tags
- uses: actions/setup-node@v3
with:
node-version: '16.x'

- name: Download Coverage Artifacts
uses: actions/download-artifact@v3
with:
name: ${{github.run_number}}-${{github.run_attempt}}-coverage

- name: Install Codecov CLI
run : .github/workflows/scripts/install-codecov.sh

- name: Upload tests coverage report to Codecov
run: ./codecov --verbose upload-process -t ${{ secrets.CODECOV_TOKEN }} -n ${{github.run_number}}-${{github.run_attempt}}-coverage -F unit -f ./coverage/coverage-unit.json

check-e2e-tags:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/setup-node@v3
with:
node-version: '16.x'
- name: Check e2e tags
run: |
./scripts/check-e2e-tests-for-tags
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,6 @@ scripts/standalone/node
# yarn.lock files
docusaurus/yarn.lock
storybook/yarn.lock

# GitHub actions scripts output
codecov
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import SelectOrCreateAuthSecret from '@shell/components/form/SelectOrCreateAuthS
import CreateEditView from '@shell/mixins/create-edit-view';
import SecretSelector from '@shell/components/form/SecretSelector';
import { SECRET_TYPES as TYPES } from '@shell/config/secret';
import { base64Decode, base64Encode } from '@shell/utils/crypto';
export default {
components: {
Expand Down Expand Up @@ -55,7 +56,7 @@ export default {
if (configMap[hostname]) {
configMap[hostname].insecureSkipVerify = configMap[hostname].insecureSkipVerify ?? defaultAddValue.insecureSkipVerify;
configMap[hostname].authConfigSecretName = configMap[hostname].authConfigSecretName ?? defaultAddValue.authConfigSecretName;
configMap[hostname].caBundle = configMap[hostname].caBundle ?? defaultAddValue.caBundle;
configMap[hostname].caBundle = base64Decode(configMap[hostname].caBundle ?? defaultAddValue.caBundle);
configMap[hostname].tlsSecretName = configMap[hostname].tlsSecretName ?? defaultAddValue.tlsSecretName;
}
entries.push({
Expand Down Expand Up @@ -94,7 +95,11 @@ export default {
continue;
}
configs[h] = { ...entry };
configs[h] = {
...entry,
caBundle: base64Encode(entry.caBundle)
};
delete configs[h].hostname;
}
Expand Down Expand Up @@ -177,6 +182,7 @@ export default {
<LabeledInput
v-model="row.value.caBundle"
:data-testid="`registry-caBundle-${i}`"
class="mt-20"
type="multiline"
label="CA Cert Bundle"
Expand Down
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==');
});
});
});

0 comments on commit 83b08d0

Please sign in to comment.