Skip to content

Commit

Permalink
tests: Refactor harbor end-to-end tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aarnq committed Nov 10, 2023
1 parent a8292a0 commit da71906
Show file tree
Hide file tree
Showing 5 changed files with 298 additions and 142 deletions.
20 changes: 0 additions & 20 deletions tests/end-to-end/harbor-admin-static-user.cy.js

This file was deleted.

96 changes: 96 additions & 0 deletions tests/end-to-end/harbor-authentication.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
function harborAdminLogin(cy, ingress) {
cy.visit(`https://${ingress}/account/sign-in`)

cy.contains("LOGIN VIA LOCAL DB")
.click()

cy.yqSecrets(".harbor.password")
.then(password => {
cy.get('input[placeholder*="Username"]')
.type("admin", { log: false })

cy.get('input[placeholder*="Password"]')
.type(password, { log: false })


cy.get("button")
.contains("LOG IN")
.click()
})

cy.contains("Projects")
.should("exist")

cy.contains("admin")
.should("exist")
}

describe("harbor authentication", function() {
before(function() {
cy.yq("sc", '.harbor.subdomain + "." + .global.baseDomain')
.should("not.be.empty")
.as('ingress')
})

it("can login via static admin user", function() {
harborAdminLogin(cy, this.ingress)
})

it("can login via static dex user", function() {
cy.yqDig("sc", ".dex.enableStaticLogin")
.then(staticLoginEnabled => {
if (staticLoginEnabled !== "true") {
this.skip("dex static login is not enabled")
}
})

cy.visit(`https://${this.ingress}`)

cy.dexStaticLogin()

cy.url().then(url => {
if (url.includes("oidc-onboard")) {
cy.contains("label", "Username")
.siblings()
.get("input")
.clear()
.type("dex-static-user")

cy.contains("SAVE")
.click()
}
})

cy.contains("Projects")
.should("exist")

cy.contains("dex-static-user")
.should("exist")
})

it("promote static dex user to admin", function() {
harborAdminLogin(cy, this.ingress)

cy.contains("Users")
.click()

cy.contains("[email protected]")
.parent()
.parent()
.parent()
.find("input[type=checkbox]")
.check({ force: true })

cy.get("button[id=set-admin]")
.then(element => {
if (element.text().includes("SET AS ADMIN")) {
cy.wrap(element)
.click()
}
})

cy.contains("[email protected]")
.siblings()
.contains("Yes")
})
})
102 changes: 0 additions & 102 deletions tests/end-to-end/harbor-create-user-project.cy.js

This file was deleted.

Loading

0 comments on commit da71906

Please sign in to comment.