Skip to content

Commit

Permalink
[bidi][js] Add 'continueWithAuth' command
Browse files Browse the repository at this point in the history
  • Loading branch information
pujagani committed Feb 13, 2024
1 parent 4eeeba7 commit d3bba9e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
16 changes: 16 additions & 0 deletions javascript/node/selenium-webdriver/bidi/network.js
Expand Up @@ -108,6 +108,22 @@ class Network {
await this.bidi.send(command)
}

async continueWithAuth(requestId, username, password) {
const command = {
method: 'network.continueWithAuth',
params: {
request: requestId.toString(),
action: 'provideCredentials',
credentials: {
type: 'password',
username: username,
password: password
},
},
}
await this.bidi.send(command)
}

async continueWithAuthNoCredentials(requestId) {
const command = {
method: 'network.continueWithAuth',
Expand Down
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/lib/test/fileserver.js
Expand Up @@ -201,7 +201,7 @@ function sendBasicAuth(request, response) {

const userNameAndPass = Buffer.from(match[1], 'base64').toString()
const parts = userNameAndPass.split(':', 2)
if (parts[0] !== 'genie' && parts[1] !== 'bottle') {
if (parts[0] !== 'genie' || parts[1] !== 'bottle') {
denyAccess()
return
}
Expand Down
Expand Up @@ -59,7 +59,20 @@ suite(
await network.removeIntercept(intercept)
})

xit('can continue without auth credentials ', async function () {
xit('can continue with auth credentials ', async function () {
await network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED))

await network.authRequired(async (event) => {
await network.continueWithAuth(event.request.request, 'genie','bottle')
})
await driver.get(Pages.basicAuth)

await driver.wait(until.elementLocated(By.css('pre')))
let source = await driver.getPageSource()
assert.equal(source.includes('Access granted'), true)
})

it('can continue without auth credentials ', async function () {
await network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED))

await network.authRequired(async (event) => {
Expand Down

0 comments on commit d3bba9e

Please sign in to comment.