Skip to content

Commit 1f257f3

Browse files
xingzhang-suselsongsuse
authored andcommitted
Added readme content for installation instruction, Supplyment unit test cases, Fix a unitest bug
1 parent a27cd2f commit 1f257f3

File tree

3 files changed

+95
-2
lines changed

3 files changed

+95
-2
lines changed

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,27 @@
1-
# security-ui-exts
1+
# security-ui-exts
2+
3+
### Development environment setup
4+
#### Environment requirement
5+
6+
##### VM server
7+
- Linux
8+
- kubernetes
9+
- Rancher manager 2.9 ~ 2.12
10+
##### Local computer
11+
- node.js v20 and up
12+
- npm 10 and up
13+
14+
#### Backend installation
15+
16+
##### Rancher manager
17+
- [Installing/Upgrading Rancher](https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade)
18+
19+
##### SBOMBastic
20+
- [Quickstart](docs/installation/quickstart.md)
21+
- [Uninstall](docs/installation/uninstall.md)
22+
23+
#### Frontend development environment setup
24+
25+
- Pull the code to your local computer
26+
- Run `yarn` to install dependency packages
27+
- Run `API=<Rancher UI's URL> yarn dev` to start the Rancher manager UI with security-ui-ext

pkg/sbombastic-image-vulnerability-scanner/pages/c/_cluster/sbombastic-image-vulnerability-scanner/RegistriesConfiguration.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@
235235
this.selectedRows = selected || [];
236236
},
237237
async promptRemoveRegistry() {
238-
const table = this.$refs.registryTable.$refs.table.$refs.table;
238+
const table = this.$refs.registryTable;
239239
const act = findBy(table.availableActions, 'action', 'promptRemove');
240240
if ( act ) {
241241
table.setBulkActionOfInterest(act);

pkg/sbombastic-image-vulnerability-scanner/pages/c/_cluster/sbombastic-image-vulnerability-scanner/__tests__/RegistriesConfiguration.spec.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,71 @@ describe('registries.vue', () => {
8888
expect(rows[0].metadata.name).toBe('reg1');
8989
});
9090

91+
it('summarizes registry scan data correctly', () => {
92+
const wrapper = factory();
93+
const registriesCRD = [
94+
{
95+
metadata: { name: 'reg1', namespace: 'ns1', creationTimestamp: '2023-01-01T00:00:00Z' },
96+
spec: { uri: 'http://test.uri' },
97+
scanRec: { currStatus: 'complete', previousStatus: 'pending', lastTransitionTime: '2023-01-02T00:00:00Z' }
98+
}
99+
];
100+
101+
const { registryStatusList, statusSummary } = wrapper.vm.getSummaryData(registriesCRD);
102+
103+
expect(registryStatusList[0].registryName).toBe('reg1');
104+
expect(statusSummary.complete).toBe(1);
105+
});
106+
it('updates filter status when filterByStatus is called', () => {
107+
const wrapper = factory();
108+
wrapper.vm.filterByStatus('pending');
109+
expect(wrapper.vm.filters.statusSearch).toBe('pending');
110+
});
111+
it('filters rows correctly by registry, namespace, uri, repository, and status', () => {
112+
const wrapper = factory();
113+
(wrapper.vm.rows as any[]) = [{
114+
metadata: { name: 'reg1', namespace: 'ns1' },
115+
spec: { uri: 'http://my-uri', repositories: ['repo1'] },
116+
scanRec: { currStatus: 'complete' }
117+
}];
118+
119+
wrapper.vm.filters = {
120+
registrySearch: 'reg1',
121+
namespaceSearch: 'ns1',
122+
uriSearch: 'uri',
123+
repositorySearch: 'repo1',
124+
statusSearch: 'complete'
125+
};
126+
127+
const filtered = wrapper.vm.filteredRows;
128+
expect(filtered).toHaveLength(1);
129+
expect(filtered[0].metadata.name).toBe('reg1');
130+
});
131+
it('formats latest update time correctly', () => {
132+
const wrapper = factory();
133+
wrapper.vm.latestUpdateTime = new Date('2023-01-01T12:34:56Z');
134+
expect(wrapper.vm.latestUpdateDateText).toContain('2023'); // year included
135+
expect(wrapper.vm.latestUpdateTimeText).toMatch(/\d/); // time string
136+
});
137+
it('fetchSecondaryResources returns scan jobs', async () => {
138+
storeMock.dispatch.mockResolvedValueOnce([{ id: 'scanJob1' }]);
139+
const wrapper = factory();
140+
const result = await wrapper.vm.fetchSecondaryResources({ canPaginate: false });
141+
expect(result).toEqual([{ id: 'scanJob1' }]);
142+
});
143+
144+
it('fetchPageSecondaryResources fetches scan jobs with pagination', async () => {
145+
const scanJob = { id: 'scanJob1' };
146+
storeMock.dispatch.mockResolvedValueOnce([scanJob]);
147+
148+
const wrapper = factory();
149+
const result = await wrapper.vm.fetchPageSecondaryResources({
150+
canPaginate: true,
151+
force: true,
152+
page: [{ metadata: { namespace: 'ns1', name: 'job1' } }]
153+
});
154+
155+
expect(storeMock.dispatch).toHaveBeenCalledWith('cluster/findPage', expect.any(Object));
156+
expect(result).toEqual([scanJob]);
157+
});
91158
});

0 commit comments

Comments
 (0)