Skip to content

Commit

Permalink
tests: Add e2e Harbor static Dex login
Browse files Browse the repository at this point in the history
  • Loading branch information
crssnd committed Oct 17, 2023
1 parent 1acef3c commit bd3eff7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/cypress.support.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,13 @@ Cypress.Commands.add("dexStaticUserLogin", function(username, loginUrl, cookieNa
// {enter} causes the form to submit
cy.get('input#password').type(`${password}{enter}`, { log: false })
})

// this is needed for Harbor first time login
cy.title().then(($title) => {
if ($title === 'Harbor') {
cy.wait(1000)
cy.get("body").then(($body) => {
const hasOidcBanner = $body[0].querySelectorAll("*[class='modal-title oidc-header-text']")
cy.log(hasOidcBanner)
if (hasOidcBanner.length > 0) {
cy.get('input[name=oidcUsername]').clear().type('admin_static_user')
cy.contains('button', 'SAVE').click()
Expand Down
16 changes: 16 additions & 0 deletions tests/end-to-end/harbor-static-dex-user.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
describe("harbor static dex user", function() {
before(function() {
cy.yq("sc", "\"https://\" + .harbor.subdomain + \".\" + .global.baseDomain")
.should("not.be.empty")
.as('baseUrl')
})
beforeEach(function() {
cy.dexStaticUserLogin("[email protected]", this.baseUrl, 'sid')
})

it('Harbor landing page is visible', function () {
cy.visit(this.baseUrl)
cy.get('[class="header-title"]').should('exist').and('contain', 'Projects')
cy.contains('button', 'admin_static_user').click()
})
})

0 comments on commit bd3eff7

Please sign in to comment.