From 76f9a02540abd3f44c9d8d6d384bc464b3c2bf47 Mon Sep 17 00:00:00 2001 From: David Ma <40131297+davidma415@users.noreply.github.com> Date: Tue, 20 Feb 2024 10:18:19 -0700 Subject: [PATCH] feat: display auth strategy info in application view (#406) --- .../specs/application_registration.spec.ts | 96 +++++++++++++++++++ src/locales/ca_ES.ts | 4 +- src/locales/de.ts | 4 +- src/locales/en.ts | 4 +- src/locales/es_ES.ts | 4 +- src/locales/fr.ts | 4 +- src/locales/i18n-type.d.ts | 4 +- src/views/Applications/ApplicationDetail.vue | 96 +++++++++++++++++++ src/views/Spec.vue | 27 +++--- 9 files changed, 224 insertions(+), 19 deletions(-) diff --git a/cypress/e2e/specs/application_registration.spec.ts b/cypress/e2e/specs/application_registration.spec.ts index 5aa37ae2..5bfcd161 100644 --- a/cypress/e2e/specs/application_registration.spec.ts +++ b/cypress/e2e/specs/application_registration.spec.ts @@ -1252,6 +1252,33 @@ describe('Application Registration', () => { cy.get('[data-testid="client-secret-table"] [data-testid="refresh-secret-button"]').should('not.exist') cy.get('.credentials-list').should('exist') }) + it('app-reg-v2 - show auth strategy info for key-auth app', () => { + cy.mockLaunchDarklyFlags([ + { + name: 'tdx-3531-app-reg-v2', + value: true + } + ]) + const keyAuthApp = { + ...apps[0], + auth_strategy: { + id: 'key-auth-strat-id', + name: 'keyauthstrat', + credential_type: AuthStrategyKeyAuthCredentialTypeEnum.KeyAuth + } + } + + cy.mockApplications([{ ...keyAuthApp }], 1) + mockApplicationWithCredAndReg({ ...keyAuthApp }) + + cy.visit('/my-apps') + + cy.get('[data-testid="applications-table"] tbody tr').click() + cy.get('[data-testid="auth-strategy-card"]').should('exist') + cy.get('[data-testid="auth-strategy-auth-methods-label"]').should('not.exist') + cy.get('[data-testid="auth-strategy-title"]').should('exist').should('contain.text', keyAuthApp.auth_strategy.name) + cy.get('[data-testid="auth-strategy-credential-type"]').should('exist').should('contain.text', 'Key Auth') + }) it('app-reg-v2 - does not show any tables if app is oidc ', () => { cy.mockLaunchDarklyFlags([ { @@ -1284,7 +1311,41 @@ describe('Application Registration', () => { cy.get('[data-testid="client-secret-table"] [data-testid="refresh-secret-button"]').should('not.exist') cy.get('.credentials-list').should('not.exist') }) + it('app-reg-v2 - show auth strategy info for oidc app', () => { + cy.mockLaunchDarklyFlags([ + { + name: 'tdx-3531-app-reg-v2', + value: true + } + ]) + const oidcApp = { + ...apps[0], + auth_strategy: { + id: 'oidc-strat-id', + name: 'oidc-strat', + auth_methods: [ + 'client_credentials', + 'session', + 'bearer' + ], + credential_type: AuthStrategyClientCredentialsCredentialTypeEnum.SelfManagedClientCredentials + } + } + + cy.mockApplications([{ ...oidcApp }], 1) + mockApplicationWithCredAndReg({ ...oidcApp }) + cy.visit('/my-apps') + + cy.get('[data-testid="applications-table"] tbody tr').click() + cy.get('[data-testid="auth-strategy-card"]').should('exist') + cy.get('[data-testid="auth-strategy-auth-methods-label"]').should('exist') + cy.get('[data-testid="auth-strategy-title"]').should('exist').should('contain.text', oidcApp.auth_strategy.name) + cy.get('[data-testid="auth-strategy-credential-type"]').should('exist').should('contain.text', 'Self Managed Client Credentials') + oidcApp.auth_strategy.auth_methods.forEach((method) => { + cy.get(`[data-testid="auth-method-${method}"]`).should('exist') + }) + }) it('app-reg-v2 - show dcr token table if app is DCR ', () => { cy.mockLaunchDarklyFlags([ { @@ -1341,6 +1402,41 @@ describe('Application Registration', () => { cy.get('[data-testid="application-secret-token-modal"]').should('not.exist') }) + it('app-reg-v2 - show auth strategy info for dcr app', () => { + cy.mockLaunchDarklyFlags([ + { + name: 'tdx-3531-app-reg-v2', + value: true + } + ]) + const dcrApp = { + ...apps[0], + auth_strategy: { + id: 'okta-strat-id', + name: 'dcr-strat', + auth_methods: [ + 'bearer', + 'client_credentials', + 'session' + ], + credential_type: AuthStrategyClientCredentialsCredentialTypeEnum.ClientCredentials + } + } + + cy.mockApplications([{ ...dcrApp }], 1) + mockApplicationWithCredAndReg({ ...dcrApp }) + + cy.visit('/my-apps') + + cy.get('[data-testid="applications-table"] tbody tr').click() + cy.get('[data-testid="auth-strategy-card"]').should('exist') + cy.get('[data-testid="auth-strategy-auth-methods-label"]').should('exist') + cy.get('[data-testid="auth-strategy-title"]').should('exist').should('contain.text', dcrApp.auth_strategy.name) + cy.get('[data-testid="auth-strategy-credential-type"]').should('exist').should('contain.text', 'Client Credentials') + dcrApp.auth_strategy.auth_methods.forEach((method) => { + cy.get(`[data-testid="auth-method-${method}"]`).should('exist') + }) + }) describe('Credential management with DCR', () => { it('can refresh token of existing application with dcr', () => { diff --git a/src/locales/ca_ES.ts b/src/locales/ca_ES.ts index 574f8219..ee6ecdfa 100644 --- a/src/locales/ca_ES.ts +++ b/src/locales/ca_ES.ts @@ -45,12 +45,14 @@ export const ca_ES: I18nType = { registerProductVersion: translationNeeded(en.productVersion.registerProductVersion) }, authStrategyInfo: { - title: (authStrategyName: string) => translationNeeded(en.authStrategyInfo.title(authStrategyName)), + titleLabel: translationNeeded(en.authStrategyInfo.titleLabel), + credentialTypeLabel: translationNeeded(en.authStrategyInfo.credentialTypeLabel), registerBtnText: (productVersionName: string) => translationNeeded(en.authStrategyInfo.registerBtnText(productVersionName)), authMethods: translationNeeded(en.authStrategyInfo.authMethods), bearer: translationNeeded(en.authStrategyInfo.bearer), keyAuth: translationNeeded(en.authStrategyInfo.keyAuth), clientCredentials: translationNeeded(en.authStrategyInfo.clientCredentials), + selfManagedClientCredentials: translationNeeded(en.authStrategyInfo.selfManagedClientCredentials), session: translationNeeded(en.authStrategyInfo.session) }, userDropdown: { diff --git a/src/locales/de.ts b/src/locales/de.ts index fb66ad68..6f5ab494 100644 --- a/src/locales/de.ts +++ b/src/locales/de.ts @@ -45,12 +45,14 @@ export const de: I18nType = { registerProductVersion: translationNeeded(en.productVersion.registerProductVersion) }, authStrategyInfo: { - title: (authStrategyName: string) => translationNeeded(en.authStrategyInfo.title(authStrategyName)), + titleLabel: translationNeeded(en.authStrategyInfo.titleLabel), + credentialTypeLabel: translationNeeded(en.authStrategyInfo.credentialTypeLabel), registerBtnText: (productVersionName: string) => translationNeeded(en.authStrategyInfo.registerBtnText(productVersionName)), authMethods: translationNeeded(en.authStrategyInfo.authMethods), bearer: translationNeeded(en.authStrategyInfo.bearer), keyAuth: translationNeeded(en.authStrategyInfo.keyAuth), clientCredentials: translationNeeded(en.authStrategyInfo.clientCredentials), + selfManagedClientCredentials: translationNeeded(en.authStrategyInfo.selfManagedClientCredentials), session: translationNeeded(en.authStrategyInfo.session) }, userDropdown: { diff --git a/src/locales/en.ts b/src/locales/en.ts index 08384f58..306832bb 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -41,12 +41,14 @@ export const en = { registerProductVersion: 'Register Product version' }, authStrategyInfo: { - title: (authStrategyName: string) => `Supported Application Auth Strategy: ${authStrategyName}`, + titleLabel: 'Supported Application Auth Strategy:', + credentialTypeLabel: 'Credential Type:', registerBtnText: (productVersionName: string) => `Register for ${productVersionName}`, authMethods: 'Auth Methods:', bearer: 'Bearer', keyAuth: 'Key Auth', clientCredentials: 'Client Credentials', + selfManagedClientCredentials: 'Self Managed Client Credentials', session: 'Session' }, userDropdown: { diff --git a/src/locales/es_ES.ts b/src/locales/es_ES.ts index 868b530c..d92f7c23 100644 --- a/src/locales/es_ES.ts +++ b/src/locales/es_ES.ts @@ -45,12 +45,14 @@ export const es_ES: I18nType = { registerProductVersion: translationNeeded(en.productVersion.registerProductVersion) }, authStrategyInfo: { - title: (authStrategyName: string) => translationNeeded(en.authStrategyInfo.title(authStrategyName)), + titleLabel: translationNeeded(en.authStrategyInfo.titleLabel), + credentialTypeLabel: translationNeeded(en.authStrategyInfo.credentialTypeLabel), registerBtnText: (productVersionName: string) => translationNeeded(en.authStrategyInfo.registerBtnText(productVersionName)), authMethods: translationNeeded(en.authStrategyInfo.authMethods), bearer: translationNeeded(en.authStrategyInfo.bearer), keyAuth: translationNeeded(en.authStrategyInfo.keyAuth), clientCredentials: translationNeeded(en.authStrategyInfo.clientCredentials), + selfManagedClientCredentials: translationNeeded(en.authStrategyInfo.selfManagedClientCredentials), session: translationNeeded(en.authStrategyInfo.session) }, userDropdown: { diff --git a/src/locales/fr.ts b/src/locales/fr.ts index e9d3fae6..7d944e41 100644 --- a/src/locales/fr.ts +++ b/src/locales/fr.ts @@ -45,12 +45,14 @@ export const fr: I18nType = { registerProductVersion: 'Enregistrer une version de produit' }, authStrategyInfo: { - title: (authStrategyName: string) => translationNeeded(en.authStrategyInfo.title(authStrategyName)), + titleLabel: translationNeeded(en.authStrategyInfo.titleLabel), + credentialTypeLabel: translationNeeded(en.authStrategyInfo.credentialTypeLabel), registerBtnText: (productVersionName: string) => translationNeeded(en.authStrategyInfo.registerBtnText(productVersionName)), authMethods: translationNeeded(en.authStrategyInfo.authMethods), bearer: translationNeeded(en.authStrategyInfo.bearer), keyAuth: translationNeeded(en.authStrategyInfo.keyAuth), clientCredentials: translationNeeded(en.authStrategyInfo.clientCredentials), + selfManagedClientCredentials: translationNeeded(en.authStrategyInfo.selfManagedClientCredentials), session: translationNeeded(en.authStrategyInfo.session) }, userDropdown: { diff --git a/src/locales/i18n-type.d.ts b/src/locales/i18n-type.d.ts index cf258952..b5ce23a8 100644 --- a/src/locales/i18n-type.d.ts +++ b/src/locales/i18n-type.d.ts @@ -41,12 +41,14 @@ export interface I18nType { registerProductVersion: string; }; authStrategyInfo: { - title: (authStrategyName: string) => string; + titleLabel: string; + credentialTypeLabel: string; registerBtnText: (productVersionName: string) => string; authMethods: string; bearer: string; keyAuth: string; clientCredentials: string; + selfManagedClientCredentials: string; session: string; }; userDropdown: { diff --git a/src/views/Applications/ApplicationDetail.vue b/src/views/Applications/ApplicationDetail.vue index bdd5724f..5d99c4a4 100644 --- a/src/views/Applications/ApplicationDetail.vue +++ b/src/views/Applications/ApplicationDetail.vue @@ -14,6 +14,56 @@ v-if="currentState.matches('success')" >
+ + + $route.params.application_id as string) const breadcrumbs = computed(() => ([{ key: 'my-apps', @@ -204,6 +261,8 @@ export default defineComponent({ }) return { + appRegV2Enabled, + authMethodLabelObj, analyticsCardTitle, currentState, errorMessage, @@ -219,3 +278,40 @@ export default defineComponent({ } }) + + diff --git a/src/views/Spec.vue b/src/views/Spec.vue index 7a264663..30d21397 100644 --- a/src/views/Spec.vue +++ b/src/views/Spec.vue @@ -11,12 +11,15 @@ data-testid="auth-strategy-card" >