Skip to content

Commit cd65861

Browse files
authored
fix: Adding own module-template CM with github raw link (#4632)
* fix: Handle raw github links * Adjust tests * Adjust tests
1 parent b7315f6 commit cd65861

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

backend/modules/communityRouter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async function handleGetCommunityResource(req, res) {
1717
try {
1818
const url = new URL(link);
1919
// Only allow HTTPS protocol and restrict to specific trusted domains.
20-
const allowedDomains = ['github.com', 'github.io'];
20+
const allowedDomains = ['githubusercontent.com', 'github.com', 'github.io'];
2121
if (
2222
url.protocol !== 'https:' ||
2323
!allowedDomains.some((domain) => url.hostname.endsWith(domain))

src/components/Modules/community/components/AddSourceYamls.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ export const AddSourceYamls = () => {
237237
if (allTemplatesInstalled) {
238238
return (
239239
<>
240-
<Text>
240+
<Text data-testid="error-all-modules-installed">
241241
{t('modules.community.source-yaml.all-modules-installed')}
242242
</Text>
243243
{displayExistingModulesList(existingModuleTemplates)}

tests/integration/tests/kyma-cluster/test-community-modules.spec.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ context('Test Community Modules views', () => {
8989
// Open Add YAML
9090
cy.get('[accessible-name="add-yamls"]').click();
9191

92-
// Uncomment and adjust with https://github.com/kyma-project/busola/issues/4587
93-
// cy.get('[accessible-name="Source YAML URL"]').click().type(
94-
// 'https://raw.githubusercontent.com/kyma-project/community-modules/main/all-modules.yaml',
95-
// );
96-
9792
// Open Add to Namespace select
9893
cy.get(`[header-text="Add Source YAML"]:visible`)
9994
.find('[data-testid="add-to-namespace-select"]')
@@ -109,6 +104,20 @@ context('Test Community Modules views', () => {
109104
// Click of default namespace
110105
cy.get('ui5-option-custom:visible').contains('default').click();
111106

107+
// Check access to raw github files
108+
cy.get('[accessible-name="Source YAML URL"]')
109+
.find('input')
110+
.click()
111+
.clear()
112+
.type(
113+
'https://raw.githubusercontent.com/kyma-project/busola/refs/heads/main/tests/integration/fixtures/community-modules/busola-0-12.yaml',
114+
);
115+
116+
// Check if error 'all modules installed' is displayed
117+
cy.get('[data-testid="error-all-modules-installed"]')
118+
.contains('All modules in this YAML are already installed.')
119+
.should('be.visible');
120+
112121
cy.get('ui5-button:visible').contains('Cancel').click();
113122
});
114123

0 commit comments

Comments
 (0)