Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into docs/wdi5-2
Browse files Browse the repository at this point in the history
  • Loading branch information
vobu committed Sep 8, 2023
2 parents 3506824 + ec8a42e commit 09035a6
Show file tree
Hide file tree
Showing 20 changed files with 6,754 additions and 899 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/wdi5-tests_auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
submodules: recursive

- name: use node ${{ matrix.node-version }}
uses: actions/setup-node@v3
Expand All @@ -67,6 +68,11 @@ jobs:
- name: build
run: npm run build

# this against the submodule cloned from https://github.com/SAP-samples/cap-bookshop-wdi5
- name: local CAP authentication
run: npm run test:capAuth

# this against deployed TS sample app on BTP
- name: (browserstack) btp/sap cloud id, basic auth, office 365, custom auth
run: BROWSERSTACK=true npm run test:auth

Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "examples/cap-bookshop-wdi5"]
path = examples/cap-bookshop-wdi5
url = [email protected]:SAP-samples/cap-bookshop-wdi5.git
branch = wdi5-tests
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.0.0-rc.0](https://github.com/ui5-community/wdi5/compare/v2.0.0-beta.1...v2.0.0-rc.0) (2023-09-08)


### Features

* support cap basic auth ([fd7b99e](https://github.com/ui5-community/wdi5/commit/fd7b99e8945742ea3cf106f948e3f83e5d97064d)), closes [#502](https://github.com/ui5-community/wdi5/issues/502)
* wdi5^2 treats ([#535](https://github.com/ui5-community/wdi5/issues/535)) ([a186d14](https://github.com/ui5-community/wdi5/commit/a186d143201568d57d6ab57a3379196de84cdf08))


### Bug Fixes

* safeguard devtools protocol stale web element ref ([#524](https://github.com/ui5-community/wdi5/issues/524)) ([ece986f](https://github.com/ui5-community/wdi5/commit/ece986f16f10426370fad4eb6d79b5f983262ab6))
* remove it.only from stale element tests ([7bb89f1](https://github.com/ui5-community/wdi5/commit/7bb89f12f83ecc96acfee2f4fe55773cf72856c5))

## [2.0.0-beta.1](https://github.com/ui5-community/wdi5/compare/v2.0.0-beta.0...v2.0.0-beta.1) (2023-08-29)


Expand Down
2 changes: 1 addition & 1 deletion client-side-js/injectUI5.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ async function clientSide_injectUI5(config, waitForUI5Timeout, browserInstance)
} while ((currentObj = Object.getPrototypeOf(currentObj)))

// filter for:
// @ts-ignore
// @ts-expect-error - TS doesn't know that the keys are strings
let controlMethodsToProxy = [...properties.keys()].filter((item) => {
if (typeof control[item] === "function") {
// function
Expand Down
38 changes: 28 additions & 10 deletions docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@

Generally speaking, the authentication behavior mimicks that of a regular user session: first, the `baseUrl` (from the `wdio.conf.(j|t)s`-file) is opened in the configured browser. Then, the redirect to the Authentication provider is awaited and [the credentials](#credentials) are supplied.

BTP-, IAS-, Office365- and custom IdP all supply credentials as a user would, meaning they're literally typed into the respective input fields on each login screen.
BTP-, IAS-, Office365- and custom IdP all supply credentials as a user would, meaning they're literally typed into the respective input fields on each login screen.
Basic Authentication prepends username and password in encoded form to the URL, resulting in an `HTTP` `GET` in the form of `https://username:[email protected]`.

!> Multi-Factor Authentication is not supported as it's nearly impossible to manage any media break (e.g. browser ↔ mobile) in authentication flows out of the box

For you as users, authentication is done at design-time, meaning: **by configuration only, not programmatically**.
For you as users, authentication is done at design-time, meaning: **by configuration only, not programmatically**.
This especially means that no changes in the test code are needed for using authentication in `wdi5` tests!

?> No [skipping of the UI5 injection](configuration#skipinjectui5onstart) is necessary, `wdi5` takes care of the correct order of operation (first authentication, then injecting UI5) itself.

!> Credentials can only be supplied via environment variables, not in any configuration file.
!> Credentials can only be supplied via environment variables, not in any configuration file.
More on the [how and why below](#credentials) :point_down:

## Configuration
Expand Down Expand Up @@ -127,8 +127,8 @@ The `BTP` authenticator will automatically detect whether the login process is a

?> only available in `wdi5` >= 2

Using the 'Identity Authentication Service (IAS) Authenticator' in `wdi5` is a subset of the [above BTP Authentication](#sap-cloud-idp-default-btp-identity-provider).
It takes the same configuration options, plus `disableBiometricAuth` (default: `true`, which you want in almost all cases) and `idpDomain`. The latter is necessary to satisfy cookie conditions in the remote-controlled browser.
Using the 'Identity Authentication Service (IAS) Authenticator' in `wdi5` is a subset of the [above BTP Authentication](#sap-cloud-idp-default-btp-identity-provider).
It takes the same configuration options, plus `disableBiometricAuth` (default: `true`, which you want in almost all cases) and `idpDomain`. The latter is necessary to satisfy cookie conditions in the remote-controlled browser.
Set `idpDomain` to the _domain-only_ part of your IAS tenant URL, e.g. `weiruhg.accounts.ondemand.com`, _omitting_ the protocol prefix (`https://`).

!> If `disableBiometricAuth` is set to `true`, `idpDomain` must be set as well!
Expand Down Expand Up @@ -310,7 +310,8 @@ baseUrl: "https://caution_your-deployed-ui5-with-basic-auth.app",
capabilities: {
// browserName: "..."
"wdi5:authentication": {
provider: "BasicAuth" //> mandatory
provider: "BasicAuth", //> mandatory
basicAuthUrls: ["https://your-custom-basic-auth-endpoint"] //> optional: default is the configured `baseUrl`
}
}
```
Expand All @@ -325,7 +326,8 @@ capabilities: {
capabilities: {
// browserName: "..."
"wdi5:authentication": {
provider: "BasicAuth" //> mandatory
provider: "BasicAuth", //> mandatory
basicAuthUrls: ["https://your-custom-basic-auth-endpoint"] //> optional: default is the configured `baseUrl`
}
}
},
Expand All @@ -334,15 +336,31 @@ capabilities: {
capabilities: {
// browserName: "..."
"wdi5:authentication": {
provider: "BasicAuth" //> mandatory
provider: "BasicAuth", //> mandatory
basicAuthUrls: ["https://your-custom-basic-auth-endpoint"] //> optional: default is the configured `baseUrl`
}
}
}
}
```

#### CAP Authentication (only during development!)
During development it is common to use basic authentication to mock users. In contrast to deployed applications we have to authenticate ourself directly to the exposed OData enpoints and not to the application itself. For that reason you have to configure the `basicAuthUrls` which should point to the OData `$metadata`.

```js
capabilities: {
// browserName: "..."
"wdi5:authentication": {
provider: "BasicAuth", //> mandatory
basicAuthUrls: ["http://localhost:4004/odata/v4/myEndpoint/$metadata", "http://localhost:4004/odata/v4/myOtherEndpoint/$metadata"]
}
}
```
If you have multiple OData endpoints you have to declare every single OData endpoint in the `basicAuthUrls` array.

<!-- tabs:end -->


## Credentials

Exposing credentials in configuration files that were accidentally checked into version control is one of the most common causes of data leaks. That's why `wdi5` only allows providing credentials through environment variables at runtime.
Expand All @@ -351,7 +369,7 @@ Exposing credentials in configuration files that were accidentally checked into

There are multiple ways to achieve that in Node.js, with [using the `dotenv`-module](https://www.npmjs.com/package/dotenv) being one of the most popular: `dotenv` automatically transfers all variables from a `.env`-file into the environment of the app at runtime.

In single browser scenarios, `wdi5_username` and `wdi5_password` need to be provided.
In single browser scenarios, `wdi5_username` and `wdi5_password` need to be provided.
In multiremote scenarios, credential keys in the environment adhere to `wdi5_$browserInstanceName_username` and `wdi5_$browserInstanceName_password`.

<!-- tabs:start -->
Expand Down Expand Up @@ -381,5 +399,5 @@ wdi5_nix_password='dmac'

## Miscellaneous

Why the `wdi5:...` prefix?
Why the `wdi5:...` prefix?
Because the W3C standard for providing options in the WebDriver protocol asks for any vendor-specfic setting to have a unique prefix.
1 change: 1 addition & 0 deletions examples/cap-bookshop-wdi5
Submodule cap-bookshop-wdi5 added at ae62c5
4 changes: 2 additions & 2 deletions examples/ui5-ts-app/test/e2e/Basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("Basic", async () => {
const view = await (browser.asControl(selector) as unknown as Page).getParent()
const controller: Controller = await (view as View).getController()

// @ts-ignore this async fn lives in an not properly typed controller
// @ts-expect-error this async fn lives in an not properly typed controller
const number = await controller.asyncFn()
expect(number).toEqual(10)
})
Expand All @@ -49,7 +49,7 @@ describe("Basic", async () => {
const view: unknown = await (browser.asControl(selector) as unknown as Page).getParent()
const controller: Controller = await (view as View).getController()

// @ts-ignore this async fn lives in an not properly typed controller
// @ts-expect-error this async fn lives in an not properly typed controller
await controller.asyncRejectFn()
expect(
(Logger.error as sinon.SinonSpy).calledWith('call of asyncRejectFn failed because of: "meh"')
Expand Down
2 changes: 1 addition & 1 deletion examples/ui5-ts-app/test/e2e/Input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("Input", async () => {
it("should retrieve the webcomponent's bound path via a managed object", async () => {
const control = await browser.asControl(inputSelector)
const bindingInfo = await control.getBindingInfo("value")
// @ts-ignore
// @ts-expect-error "parts" is not part of the type definition
const parts = await bindingInfo.parts
expect(parts[0].path).toEqual("/Customers('TRAIH')/ContactName")
})
Expand Down
2 changes: 1 addition & 1 deletion examples/ui5-ts-app/test/e2e/MultiInput.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("MultiInput", async () => {
interaction: "root"
}
}
// @ts-ignore
// @ts-expect-error we'd need to properly type the multi input control
await (browser.asControl(multiInputSelector) as unknown as MultiInput).enterText("123")

const multiInput = await browser.asControl<MultiInput>(multiInputSelector)
Expand Down
4 changes: 2 additions & 2 deletions examples/ui5-ts-app/test/e2e/multiremote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ describe("Basic", async () => {
viewName: "test.Sample.tsapp.view.Main"
}
}
// @ts-ignore
// @ts-expect-error browser ref ("two") is not properly typed
const allButtonsTwo = await browser.two.allControls<Button>(allButtonsSelector)
// @ts-ignore
// @ts-expect-error browser ref ("one") is not properly typed
const allButtonsOne = await browser.one.allControls<Button>(allButtonsSelector)
expect(allButtonsTwo.length).toEqual(1)
expect(allButtonsOne.length).toEqual(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const config: wdi5Config = {
services: ["ui5"],
specs: [resolve("test/e2e/protocol/*.test.ts")],
wdi5: {
logLevel: "verbose"
logLevel: "verbose",
waitForUI5Timeout: 25000
},
automationProtocol: "devtools",
capabilities: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export const config: wdi5Config = {
baseUrl: "https://wdi5-sample-app.cfapps.eu20.hana.ondemand.com/no-auth/",
services: ["ui5"],
wdi5: {
logLevel: "verbose"
logLevel: "verbose",
waitForUI5Timeout: 25000
},
specs: [resolve("test/e2e/protocol/*.test.ts")],
capabilities: [
Expand Down
2 changes: 1 addition & 1 deletion examples/ui5-ts-app/webapp/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta http-equiv="Cache-control" content="no-cache, no-store, must-revalidate" />
Expand Down
Loading

0 comments on commit 09035a6

Please sign in to comment.