Skip to content

Commit d3bba9e

Browse files
committed
[bidi][js] Add 'continueWithAuth' command
1 parent 4eeeba7 commit d3bba9e

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

javascript/node/selenium-webdriver/bidi/network.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,22 @@ class Network {
108108
await this.bidi.send(command)
109109
}
110110

111+
async continueWithAuth(requestId, username, password) {
112+
const command = {
113+
method: 'network.continueWithAuth',
114+
params: {
115+
request: requestId.toString(),
116+
action: 'provideCredentials',
117+
credentials: {
118+
type: 'password',
119+
username: username,
120+
password: password
121+
},
122+
},
123+
}
124+
await this.bidi.send(command)
125+
}
126+
111127
async continueWithAuthNoCredentials(requestId) {
112128
const command = {
113129
method: 'network.continueWithAuth',

javascript/node/selenium-webdriver/lib/test/fileserver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function sendBasicAuth(request, response) {
201201

202202
const userNameAndPass = Buffer.from(match[1], 'base64').toString()
203203
const parts = userNameAndPass.split(':', 2)
204-
if (parts[0] !== 'genie' && parts[1] !== 'bottle') {
204+
if (parts[0] !== 'genie' || parts[1] !== 'bottle') {
205205
denyAccess()
206206
return
207207
}

javascript/node/selenium-webdriver/test/bidi/network_commands_test.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,20 @@ suite(
5959
await network.removeIntercept(intercept)
6060
})
6161

62-
xit('can continue without auth credentials ', async function () {
62+
xit('can continue with auth credentials ', async function () {
63+
await network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED))
64+
65+
await network.authRequired(async (event) => {
66+
await network.continueWithAuth(event.request.request, 'genie','bottle')
67+
})
68+
await driver.get(Pages.basicAuth)
69+
70+
await driver.wait(until.elementLocated(By.css('pre')))
71+
let source = await driver.getPageSource()
72+
assert.equal(source.includes('Access granted'), true)
73+
})
74+
75+
it('can continue without auth credentials ', async function () {
6376
await network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED))
6477

6578
await network.authRequired(async (event) => {

0 commit comments

Comments
 (0)