From 5429c266143902df71410caae6f7ef4ad122461c Mon Sep 17 00:00:00 2001
From: henri pietila <15886900+HenriPro@users.noreply.github.com>
Date: Fri, 12 Jul 2024 11:03:18 -0700
Subject: [PATCH 1/5] fix(spec): disable register when disabled
---
src/locales/ca_ES.ts | 3 ++-
src/locales/de.ts | 3 ++-
src/locales/en.ts | 3 ++-
src/locales/es_ES.ts | 3 ++-
src/locales/fr.ts | 3 ++-
src/locales/i18n-type.d.ts | 1 +
src/views/Spec.vue | 26 +++++++++++++++++---------
7 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/src/locales/ca_ES.ts b/src/locales/ca_ES.ts
index 19dfbedb..98050054 100644
--- a/src/locales/ca_ES.ts
+++ b/src/locales/ca_ES.ts
@@ -54,7 +54,8 @@ export const ca_ES: I18nType = {
keyAuth: translationNeeded(en.authStrategyInfo.keyAuth),
clientCredentials: translationNeeded(en.authStrategyInfo.clientCredentials),
selfManagedClientCredentials: translationNeeded(en.authStrategyInfo.selfManagedClientCredentials),
- session: translationNeeded(en.authStrategyInfo.session)
+ session: translationNeeded(en.authStrategyInfo.session),
+ disabled: translationNeeded(en.authStrategyInfo.disabled)
},
userDropdown: {
myApps: 'Les meves aplicacions',
diff --git a/src/locales/de.ts b/src/locales/de.ts
index ee0a4ed4..65b8172b 100644
--- a/src/locales/de.ts
+++ b/src/locales/de.ts
@@ -54,7 +54,8 @@ export const de: I18nType = {
keyAuth: translationNeeded(en.authStrategyInfo.keyAuth),
clientCredentials: translationNeeded(en.authStrategyInfo.clientCredentials),
selfManagedClientCredentials: translationNeeded(en.authStrategyInfo.selfManagedClientCredentials),
- session: translationNeeded(en.authStrategyInfo.session)
+ session: translationNeeded(en.authStrategyInfo.session),
+ disabled: translationNeeded(en.authStrategyInfo.disabled)
},
userDropdown: {
myApps: 'Meine Applikationen',
diff --git a/src/locales/en.ts b/src/locales/en.ts
index be03e429..c06ae2f4 100644
--- a/src/locales/en.ts
+++ b/src/locales/en.ts
@@ -50,7 +50,8 @@ export const en = {
keyAuth: 'Key Auth',
clientCredentials: 'Client Credentials',
selfManagedClientCredentials: 'Self Managed',
- session: 'Session'
+ session: 'Session',
+ disabled: 'Registration for this product version is not enabled'
},
userDropdown: {
myApps: 'My Apps',
diff --git a/src/locales/es_ES.ts b/src/locales/es_ES.ts
index b7c1ed16..fbcdfbee 100644
--- a/src/locales/es_ES.ts
+++ b/src/locales/es_ES.ts
@@ -54,7 +54,8 @@ export const es_ES: I18nType = {
keyAuth: translationNeeded(en.authStrategyInfo.keyAuth),
clientCredentials: translationNeeded(en.authStrategyInfo.clientCredentials),
selfManagedClientCredentials: translationNeeded(en.authStrategyInfo.selfManagedClientCredentials),
- session: translationNeeded(en.authStrategyInfo.session)
+ session: translationNeeded(en.authStrategyInfo.session),
+ disabled: translationNeeded(en.authStrategyInfo.disabled)
},
userDropdown: {
myApps: 'Mis aplicaciones',
diff --git a/src/locales/fr.ts b/src/locales/fr.ts
index d8846498..f3d079a4 100644
--- a/src/locales/fr.ts
+++ b/src/locales/fr.ts
@@ -54,7 +54,8 @@ export const fr: I18nType = {
keyAuth: translationNeeded(en.authStrategyInfo.keyAuth),
clientCredentials: translationNeeded(en.authStrategyInfo.clientCredentials),
selfManagedClientCredentials: translationNeeded(en.authStrategyInfo.selfManagedClientCredentials),
- session: translationNeeded(en.authStrategyInfo.session)
+ session: translationNeeded(en.authStrategyInfo.session),
+ disabled: translationNeeded(en.authStrategyInfo.disabled)
},
userDropdown: {
myApps: 'Mes Applications',
diff --git a/src/locales/i18n-type.d.ts b/src/locales/i18n-type.d.ts
index 7605c47c..b3ef73ac 100644
--- a/src/locales/i18n-type.d.ts
+++ b/src/locales/i18n-type.d.ts
@@ -51,6 +51,7 @@ export interface I18nType {
clientCredentials: string;
selfManagedClientCredentials: string;
session: string;
+ disabled: string;
};
userDropdown: {
myApps: string;
diff --git a/src/views/Spec.vue b/src/views/Spec.vue
index 5be24df3..764a858a 100644
--- a/src/views/Spec.vue
+++ b/src/views/Spec.vue
@@ -6,7 +6,7 @@
@@ -197,7 +205,7 @@ export default defineComponent({
]
const applicationRegistrationEnabled = computed(() => {
- return Boolean(currentVersion.value?.registration_configs?.length && isAllowedToRegister.value)
+ return currentVersion.value?.registration_configs.some(config => config.registration_enabled) && isAllowedToRegister.value
})
const helpText = useI18nStore().state.helpText
From fdc8f67ac78d06ecca03255ce1564ef5ccca3525 Mon Sep 17 00:00:00 2001
From: henri pietila <15886900+HenriPro@users.noreply.github.com>
Date: Fri, 12 Jul 2024 11:03:18 -0700
Subject: [PATCH 2/5] lint
---
src/views/Spec.vue | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/views/Spec.vue b/src/views/Spec.vue
index 764a858a..625bb848 100644
--- a/src/views/Spec.vue
+++ b/src/views/Spec.vue
@@ -56,10 +56,13 @@
>
{{ helpText.authStrategyInfo.registerBtnText(currentVersion?.name) }}
-
+
{{ helpText.authStrategyInfo.disabled }}
-
+
From f739effa6d2540134150049c10a4ae7d8411b967 Mon Sep 17 00:00:00 2001
From: henri pietila <15886900+HenriPro@users.noreply.github.com>
Date: Fri, 12 Jul 2024 11:03:18 -0700
Subject: [PATCH 3/5] chore(deps): bump portal sdk
---
package.json | 2 +-
yarn.lock | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/package.json b/package.json
index 2d594f80..c61306fd 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,7 @@
"@kong-ui-public/spec-renderer": "2.1.23",
"@kong/kong-auth-elements": "2.12.6",
"@kong/kongponents": "8.127.0",
- "@kong/sdk-portal-js": "2.11.1",
+ "@kong/sdk-portal-js": "2.14.0",
"@xstate/vue": "2.0.0",
"axios": "1.6.7",
"date-fns": "3.3.0",
diff --git a/yarn.lock b/yarn.lock
index 370ab479..336ca450 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1169,10 +1169,10 @@
v-calendar "3.0.0-alpha.8"
vue-draggable-next "^2.2.1"
-"@kong/sdk-portal-js@2.11.1":
- version "2.11.1"
- resolved "https://registry.yarnpkg.com/@kong/sdk-portal-js/-/sdk-portal-js-2.11.1.tgz#16354d96a0e3a2c91d403990686e4235caa8787a"
- integrity sha512-uvsZ9yyznAAvMcG501EmbYxYOEo/avN3tLeqxi8M5ycJxAlaYM+WTkRD1cgyvDsP8LnP8M5VyOa/r7I59sJqiQ==
+"@kong/sdk-portal-js@2.14.0":
+ version "2.14.0"
+ resolved "https://registry.yarnpkg.com/@kong/sdk-portal-js/-/sdk-portal-js-2.14.0.tgz#f39c01a3de23270fef1ca8ad5a8e52e9a69eb6b0"
+ integrity sha512-3ZJckN0Ei1ul3k+U5wuzmlA/K2ZRw2uQmYtO0UUPfD9G5A5eiOAWvJWrHCIBYk407DOVUjto2TdCAyFnjpjpWg==
dependencies:
axios "1.6.0"
From e524dd6d1dbe22f873d04e82a89b0596ba9cac5b Mon Sep 17 00:00:00 2001
From: henri pietila <15886900+HenriPro@users.noreply.github.com>
Date: Fri, 12 Jul 2024 11:03:19 -0700
Subject: [PATCH 4/5] test(application-registration): update tests
---
cypress/e2e/fixtures/consts.ts | 31 ++++++++++++++++---
.../specs/application_registration.spec.ts | 21 ++++++++++++-
cypress/e2e/support/mock-commands.ts | 2 +-
3 files changed, 47 insertions(+), 7 deletions(-)
diff --git a/cypress/e2e/fixtures/consts.ts b/cypress/e2e/fixtures/consts.ts
index 41ef7a80..ca730848 100644
--- a/cypress/e2e/fixtures/consts.ts
+++ b/cypress/e2e/fixtures/consts.ts
@@ -7,21 +7,31 @@ const versions: ProductVersion[] = [
id: '1afac832-5b2a-474c-a56d-c241364f41cf',
name: 'v1-beta',
deprecated: false,
- registration_configs: [{ name: 'key-auth' }]
+ registration_configs: [{
+ id: crypto.randomUUID(),
+ credential_type: 'key_auth',
+ name: 'key-auth',
+ registration_enabled: true,
+ registration_auto_approve: true
+ }]
}
]
const keyAuthRegConfig: RegistrationConfiguration = {
name: 'key auth auth strategy',
credential_type: 'key_auth',
- id: 'd668b397-8a0d-482d-9b97-9e05cbfc7618'
+ id: 'd668b397-8a0d-482d-9b97-9e05cbfc7618',
+ registration_enabled: true,
+ registration_auto_approve: true
}
const oidcAuthRegConfig: RegistrationConfiguration = {
auth_methods: ['bearer', 'client_credentials'],
name: 'oidc auth strategy',
credential_type: 'client_credentials',
- id: '7b651144-0b48-431a-af9b-58604adc9268'
+ id: '7b651144-0b48-431a-af9b-58604adc9268',
+ registration_enabled: true,
+ registration_auto_approve: true
}
const versionWithOidcAuthStrategy: ProductVersion = {
@@ -42,6 +52,16 @@ const versionWithKeyAuthAuthStrategy: ProductVersion = {
]
}
+const versionWithRegistrationDisabled: ProductVersion = {
+ ...versions[0],
+ registration_configs: [
+ {
+ ...keyAuthRegConfig,
+ registration_enabled: false
+ }
+ ]
+}
+
const product: Product = {
created_at: '2022-03-23T14:52:41.893Z',
updated_at: '2022-03-23T14:52:41.893Z',
@@ -190,11 +210,12 @@ const defaultContext: PortalContext = {
oidc_auth_enabled: false,
featureset_id: '6202956f054d96149719eed0',
rbac_enabled: false,
- allowed_time_period: '2022-03-25T13:15:02.104Z'
+ allowed_time_period: '2022-03-25T13:15:02.104Z',
+ name: 'best portal'
}
const productRegistrations: GetRegistrationResponse[] = [
productRegistration
]
-export { versions, product, productVersion, productRegistration, versionWithOidcAuthStrategy, versionWithKeyAuthAuthStrategy, productRegistrations, apps, defaultContext }
+export { versions, product, productVersion, productRegistration, versionWithOidcAuthStrategy, versionWithKeyAuthAuthStrategy, versionWithRegistrationDisabled, productRegistrations, apps, defaultContext }
diff --git a/cypress/e2e/specs/application_registration.spec.ts b/cypress/e2e/specs/application_registration.spec.ts
index 6be26442..3b84ff65 100644
--- a/cypress/e2e/specs/application_registration.spec.ts
+++ b/cypress/e2e/specs/application_registration.spec.ts
@@ -1,5 +1,5 @@
import { AuthStrategyKeyAuthCredentialTypeEnum, CredentialCreationResponse, GetApplicationResponse, ListCredentialsResponse, ListCredentialsResponseDataInner, ListRegistrationsResponse } from '@kong/sdk-portal-js'
-import { product, versions, productRegistration, apps, productWithKeyAuthAppAuthStrategy, appWithAuthStrategy, versionWithKeyAuthAuthStrategy, versionWithOidcAuthStrategy, oidcApp, dcrApp } from '../fixtures/consts'
+import { product, versions, productRegistration, apps, productWithKeyAuthAppAuthStrategy, appWithAuthStrategy, versionWithKeyAuthAuthStrategy, versionWithOidcAuthStrategy, oidcApp, dcrApp, versionWithRegistrationDisabled } from '../fixtures/consts'
const mockApplicationWithCredAndReg = (
data: GetApplicationResponse,
@@ -848,6 +848,25 @@ describe('Application Registration', () => {
'You will be notified upon approval'
)
})
+ it('registration disabled if registration disabled on auth strategy', () => {
+ cy.mockProductDocument()
+ cy.mockProduct(product.id, product, [versionWithRegistrationDisabled])
+ cy.mockProductVersionApplicationRegistration(versionWithRegistrationDisabled)
+ cy.mockGetProductDocuments(product.id)
+ cy.mockProductOperations(product.id, versions[0].id)
+ cy.mockProductVersionSpec(product.id, versions[0].id)
+ cy.mockRegistrations('*', []) // mock with empty so that we add one.
+
+ cy.viewport(1440, 900)
+ cy.visit(`/spec/${product.id}`)
+ cy.get('.swagger-ui', { timeout: 12000 })
+
+ cy.mockApplications(apps, 4)
+ cy.mockProductVersionAvailableRegistrations(product.id, versions[0].id, apps)
+ cy.mockGrantedScopes(versions[0].id, apps[0].id, ['scope1', 'scope2'])
+
+ cy.get('[data-testid="app-reg-v2-register-btn"]').should('be.disabled')
+ })
it('shows information about application auth strategy (key-auth)', () => {
cy.mockProductDocument()
cy.mockProduct(product.id, product, [versionWithKeyAuthAuthStrategy])
diff --git a/cypress/e2e/support/mock-commands.ts b/cypress/e2e/support/mock-commands.ts
index c05ac296..7d75c812 100644
--- a/cypress/e2e/support/mock-commands.ts
+++ b/cypress/e2e/support/mock-commands.ts
@@ -410,7 +410,7 @@ Cypress.Commands.add('mockProductVersionApplicationRegistration', (version, conf
'GET',
`**/api/v2/application_registrations/product_versions/${version.id}`, {
body: {
- auth_config: { name: 'key-auth', config: {} },
+ auth_config: { name: 'key-auth', registration_enabled: true, config: {} },
auto_approve: false,
created_at: '2022-03-25T10:56:27.268Z',
errors: [],
From aa6647fd7e651b11fa6157ef79e787a20734fc80 Mon Sep 17 00:00:00 2001
From: henri pietila <15886900+HenriPro@users.noreply.github.com>
Date: Fri, 12 Jul 2024 11:03:19 -0700
Subject: [PATCH 5/5] chore(sdk): override type from sdk for docs
---
src/views/ProductShell.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/views/ProductShell.vue b/src/views/ProductShell.vue
index e0f133b6..3e527b0e 100644
--- a/src/views/ProductShell.vue
+++ b/src/views/ProductShell.vue
@@ -116,7 +116,7 @@ async function fetchDocumentTree () {
headers: {
accept: DocumentContentTypeEnum.VndKonnectDocumentTreejson
}
- }) as AxiosResponse
+ }) as any as AxiosResponse
productStore.setDocumentTree((res.data).data)
}