-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(authenticate): Provide credentials for HTTP authentication(redo)…
… && Fix "No usable sandbox!" with user namespace cloning enabled
- Loading branch information
Showing
5 changed files
with
116 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/// <reference lib="dom" /> | ||
|
||
// Import Astral | ||
import { launch } from "../mod.ts"; | ||
|
||
// Launch the browser | ||
const browser = await launch(); | ||
|
||
// Open a new page | ||
const page = await browser.newPage(); | ||
|
||
// Provide credentials for HTTP authentication. | ||
await page.authenticate({ username: "postman", password: "password" }); | ||
const url = "https://postman-echo.com/basic-auth"; | ||
await page.goto(url, { waitUntil: "networkidle2" }); | ||
|
||
// Get response | ||
const content = await page.evaluate(() => { | ||
return document.body.innerText; | ||
}); | ||
console.log(content); | ||
|
||
// Close the browser | ||
await browser.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/// <reference lib="dom" /> | ||
|
||
import { assertEquals, assertNotEquals } from "@std/assert"; | ||
|
||
import { launch } from "../mod.ts"; | ||
|
||
Deno.test("Testing authenticate", async (_t) => { | ||
// Open the webpage | ||
const browser = await launch({ headless: true }); | ||
const page = await browser.newPage(); | ||
|
||
// Provide credentials for HTTP authentication. | ||
await page.authenticate({ username: "postman", password: "password" }); | ||
const url = "https://postman-echo.com/basic-auth"; | ||
await page.goto(url, { waitUntil: "networkidle2" }); | ||
|
||
// Get JSON response | ||
const content = await page.evaluate(() => { | ||
return document.body.innerText; | ||
}); | ||
|
||
// Assert JSON response | ||
assertNotEquals(content, ""); | ||
const response = JSON.parse(content); | ||
assertEquals(response.authenticated, true); | ||
|
||
// Close browser | ||
await browser.close(); | ||
}); |