Skip to content

Commit

Permalink
feat(auth): first PoC with Cert Auth to BTP
Browse files Browse the repository at this point in the history
  • Loading branch information
marianfoo committed Nov 7, 2024
1 parent 6f02f00 commit edf2d82
Show file tree
Hide file tree
Showing 8 changed files with 906 additions and 7,073 deletions.
4 changes: 3 additions & 1 deletion examples/ui5-ts-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"test:lateInject": "wdio run wdio-ui5-late.conf.ts",
"test:wz": "wdio run test/e2e/workzone/wdio-ui5-workzone.conf.ts",
"authentication:btp": "wdio run test/e2e/authentication/wdio-btp-authentication.conf.ts",
"authentication:cert": "wdio run test/e2e/authentication/wdio-cert-authentication.conf.ts",
"authentication:basic-auth": "wdio run test/e2e/authentication/wdio-basic-auth-authentication.conf.ts",
"authentication:custom": "wdio run test/e2e/authentication/wdio-custom-authentication.conf.ts",
"authentication:multiRemote": "wdio run test/e2e/authentication/wdio-btp-authentication-multiremote.conf.ts",
Expand All @@ -40,6 +41,7 @@
"ui5-middleware-livereload": "latest",
"ui5-middleware-simpleproxy": "latest",
"ui5-tooling-transpile": "latest",
"wdio-ui5-service": "*"
"wdio-ui5-service": "*",
"dotenv": "16.4.5"
}
}
37 changes: 37 additions & 0 deletions examples/ui5-ts-app/test/e2e/AuthenticationCert.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { wdi5 } from "wdio-ui5-service"

describe("wdi5 authentication", async () => {
it("wdi5.isLoggedIn", async () => {
expect(await wdi5.isLoggedIn()).toBeTruthy()
})

it("should contain 'Zeis' in header title", async () => {
await browser.waitUntil(
async () => {
const state = await browser.execute(() => {
return (
window.document.readyState === "complete" &&
(!(window as any)._pendingFetchRequests || (window as any)._pendingFetchRequests === 0)
)
})
return state
},
{
timeout: 10000,
timeoutMsg: "Network did not reach idle state after 10s"
}
)

const logger = wdi5.getLogger()
logger.log("Starting test to check header title")

const headerTitle = await $("span[id='cockpitObjectPageHeader-innerTitle']")
logger.log("Found header title element")

const titleText = await headerTitle.getText()
logger.log(`Retrieved title text: "${titleText}"`)

expect(titleText).toContain("Zeis")
logger.log("Successfully verified title contains 'Zeis'")
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { resolve } from "path"
import { merge } from "ts-deepmerge"
import { config as baseConf } from "./wdio-base.conf.js"
import "dotenv/config"

const _config = {
baseUrl: "https://emea.cockpit.btp.cloud.sap/cockpit",
capabilities: baseConf.capabilities ? [...baseConf.capabilities] : []
}

delete baseConf.capabilities
delete baseConf.specs

baseConf.specs = [resolve("./test/e2e/AuthenticationCert.test.ts")]

if (process.env.BROWSERSTACK) {
_config.capabilities = _config.capabilities.map((capability) => {
const enhancedCapability = {
...capability,
"wdi5:authentication": {
provider: "Certificate",
certificateOrigin: "https://accounts.sap.com",
certificateUrl: "https://emea.cockpit.btp.cloud.sap/cockpit#/",
certificatePfxPath: "./sap.pfx",
certificatePfxPassword: process.env.SAPPFX_PASSPHRASE
}
}
return enhancedCapability
})
} else {
_config.capabilities = [
{
"wdi5:authentication": {
provider: "Certificate",
certificateOrigin: "https://accounts.sap.com",
certificateUrl: "https://emea.cockpit.btp.cloud.sap/cockpit#/",
certificatePfxPath: "./sap.pfx",
certificatePfxPassword: process.env.SAPPFX_PASSPHRASE
},
browserName: "chrome",
"goog:chromeOptions": {
args:
process.argv.indexOf("--headless") > -1
? ["headless", "disable-gpu"]
: process.argv.indexOf("--debug") > -1
? ["window-size=1440,800", "--auto-open-devtools-for-tabs"]
: ["window-size=1440,800"]
},
acceptInsecureCerts: true
}
]
}

export const config = merge(baseConf, _config)
Loading

0 comments on commit edf2d82

Please sign in to comment.