Skip to content

Commit

Permalink
Add tests for auto auth mode
Browse files Browse the repository at this point in the history
  • Loading branch information
perry-mitchell committed Mar 18, 2024
1 parent e05883b commit 7cd2251
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion test/node/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,27 @@ describe("auth", function () {
return webdav.getFileContents("/file");
});

it("should support auto-detection of password/digest auth", function () {
nock(DUMMYSERVER)
.get("/file")
.reply(200, function () {
expect(this.req.headers.authorization).to.equal("Basic dXNlcjpwYXNz");
return "";
});
const webdav = createWebDAVClient(DUMMYSERVER, {
authType: AuthType.Auto,
username: "user",
password: "pass"
});
return webdav.getFileContents("/file");
});

describe("using Digest-enabled server", function () {
beforeEach(function () {
this.client = createWebDAVClient(`http://localhost:${SERVER_PORT}/webdav/server`, {
username: SERVER_USERNAME,
password: SERVER_PASSWORD,
authType: AuthType.Digest
authType: AuthType.Auto
});
clean();
this.server = createWebDAVServer("digest");
Expand All @@ -80,5 +95,16 @@ describe("auth", function () {
expect(exists).to.be.true;
});
});

it("should support auto-detection of password/digest auth", function () {
this.client = createWebDAVClient(`http://localhost:${SERVER_PORT}/webdav/server`, {
username: SERVER_USERNAME,
password: SERVER_PASSWORD,
authType: AuthType.Auto
});
return this.client.exists("/alrighty.jpg").then(function (exists) {
expect(exists).to.be.true;
});
});
});
});

0 comments on commit 7cd2251

Please sign in to comment.