-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0d0c13
commit d23df91
Showing
15 changed files
with
161 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
frontend/packages/integration-tests-cypress/tests/app/auth-multiuser-login.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { checkErrors } from '../../support'; | ||
import { guidedTour } from '../../views/guided-tour'; | ||
import { nav } from '../../views/nav'; | ||
import { masthead } from '../../views/masthead'; | ||
|
||
describe('Auth test', () => { | ||
const KUBEADMIN_IDP = 'kube:admin'; | ||
const KUBEADMIN_USERNAME = 'kubeadmin'; | ||
|
||
afterEach(() => { | ||
checkErrors(); | ||
cy.logout(); | ||
}); | ||
|
||
if (Cypress.env('BRIDGE_KUBEADMIN_PASSWORD')) { | ||
it(`logs in as 'test' user via htpasswd identity provider`, () => { | ||
const idp = Cypress.env('BRIDGE_HTPASSWD_IDP') || 'test'; | ||
const username = Cypress.env('BRIDGE_HTPASSWD_USERNAME') || 'test'; | ||
const passwd = Cypress.env('BRIDGE_HTPASSWD_PASSWORD') || 'test'; | ||
cy.login(idp, username, passwd); | ||
cy.url().should('include', Cypress.config('baseUrl')); | ||
guidedTour.close(); | ||
masthead.username.shouldHaveText(username); | ||
|
||
cy.log('switches from dev to admin perspective'); | ||
nav.sidenav.switcher.shouldHaveText('Developer'); | ||
nav.sidenav.switcher.changePerspectiveTo('Administrator'); | ||
nav.sidenav.switcher.shouldHaveText('Administrator'); | ||
|
||
cy.log('does not show admin nav items in Administration to test user'); | ||
nav.sidenav.shouldNotHaveNavSection(['Administration', 'Cluster Status']); | ||
nav.sidenav.shouldNotHaveNavSection(['Administration', 'Cluster Settings']); | ||
nav.sidenav.shouldNotHaveNavSection(['Administration', 'Namespaces']); | ||
nav.sidenav.shouldNotHaveNavSection(['Administration', 'Custom Resource Definitions']); | ||
|
||
cy.log('does not show admin nav items in Operators to test user'); | ||
nav.sidenav.shouldNotHaveNavSection(['Operators', 'OperatorHub']); | ||
|
||
cy.log('does not show admin nav items in Storage to test user'); | ||
nav.sidenav.shouldNotHaveNavSection(['Storage', 'Persistent Volumes']); | ||
|
||
cy.log('does not show Compute or Monitoring to test user'); | ||
nav.sidenav.shouldNotHaveNavSection(['Compute']); | ||
nav.sidenav.shouldNotHaveNavSection(['Monitoring']); | ||
}); | ||
} | ||
|
||
it(`log in as 'kubeadmin' user`, () => { | ||
cy.login(KUBEADMIN_IDP, KUBEADMIN_USERNAME, Cypress.env('BRIDGE_KUBEADMIN_PASSWORD')); | ||
cy.visit(''); | ||
cy.url().should('include', Cypress.config('baseUrl')); | ||
masthead.username.shouldHaveText(KUBEADMIN_IDP); | ||
cy.byTestID('global-notifications').contains( | ||
'You are logged in as a temporary administrative user. Update the cluster OAuth configuration to allow others to log in.', | ||
); | ||
|
||
cy.log('verify sidenav menus and Administration menu access for cluster admin user'); | ||
nav.sidenav.shouldHaveNavSection(['Compute']); | ||
nav.sidenav.shouldHaveNavSection(['Operators']); | ||
nav.sidenav.clickNavLink(['Administration', 'Cluster Settings']); | ||
cy.byLegacyTestID('cluster-settings-page-heading').should('be.visible'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
frontend/packages/integration-tests-cypress/views/guided-tour.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const guidedTour = { | ||
close: () => { | ||
cy.get('body').then(($body) => { | ||
if ($body.find(`[data-test="guided-tour-modal"]`).length) { | ||
cy.byTestID('tour-step-footer-secondary') | ||
.contains('Skip tour') | ||
.click(); | ||
} | ||
}); | ||
}, | ||
}; |
12 changes: 12 additions & 0 deletions
12
frontend/packages/integration-tests-cypress/views/masthead.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export const masthead = { | ||
username: { | ||
shouldBeVisible: () => | ||
cy | ||
.byTestID(Cypress.env('BRIDGE_KUBEADMIN_PASSWORD') ? 'user-dropdown' : 'username') | ||
.should('be.visible'), | ||
shouldHaveText: (text: string) => | ||
cy | ||
.byTestID(Cypress.env('BRIDGE_KUBEADMIN_PASSWORD') ? 'user-dropdown' : 'username') | ||
.should('have.text', text), | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export const nav = { | ||
sidenav: { | ||
switcher: { | ||
shouldHaveText: (text: string) => | ||
cy.byLegacyTestID('perspective-switcher-toggle').contains(text), | ||
changePerspectiveTo: (newPerspective: string) => | ||
cy | ||
.byLegacyTestID('perspective-switcher-toggle') | ||
.click() | ||
.byLegacyTestID('perspective-switcher-menu-option') | ||
.contains(newPerspective) | ||
.click(), | ||
}, | ||
shouldHaveNavSection: (path: string[]) => { | ||
cy.get('#page-sidebar').contains(path[0]); | ||
if (path.length === 2) { | ||
cy.get('#page-sidebar').contains(path[1]); | ||
} | ||
}, | ||
shouldNotHaveNavSection: (path: string[]) => { | ||
cy.get('#page-sidebar').should('not.have.text', path[0]); | ||
if (path.length === 2) { | ||
cy.get('#page-sidebar').should('not.have.text', path[1]); | ||
} | ||
}, | ||
clickNavLink: (path: string[]) => cy.clickNavLink(path), | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters