mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
Add basic authentication related tests.
This commit is contained in:
parent
595ee97182
commit
7c2fd91271
|
@ -4,6 +4,7 @@ import EnforceInternalRedirectionsOnly from "./scenarii/EnforceInternalRedirecti
|
||||||
import AccessControl from "./scenarii/AccessControl";
|
import AccessControl from "./scenarii/AccessControl";
|
||||||
import CustomHeadersForwarded from "./scenarii/CustomHeadersForwarded";
|
import CustomHeadersForwarded from "./scenarii/CustomHeadersForwarded";
|
||||||
import SingleFactorAuthentication from "./scenarii/SingleFactorAuthentication";
|
import SingleFactorAuthentication from "./scenarii/SingleFactorAuthentication";
|
||||||
|
import BasicAuthentication from "./scenarii/BasicAuthentication";
|
||||||
|
|
||||||
AutheliaSuite('Complete configuration', __dirname + '/config.yml', function() {
|
AutheliaSuite('Complete configuration', __dirname + '/config.yml', function() {
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
|
@ -14,4 +15,5 @@ AutheliaSuite('Complete configuration', __dirname + '/config.yml', function() {
|
||||||
describe('Mongo broken connection recovery', MongoConnectionRecovery);
|
describe('Mongo broken connection recovery', MongoConnectionRecovery);
|
||||||
describe('Enforce internal redirections only', EnforceInternalRedirectionsOnly);
|
describe('Enforce internal redirections only', EnforceInternalRedirectionsOnly);
|
||||||
describe('Single factor authentication', SingleFactorAuthentication);
|
describe('Single factor authentication', SingleFactorAuthentication);
|
||||||
|
describe('Basic authentication', BasicAuthentication);
|
||||||
});
|
});
|
34
test/suites/complete/scenarii/BasicAuthentication.ts
Normal file
34
test/suites/complete/scenarii/BasicAuthentication.ts
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import Request from 'request-promise';
|
||||||
|
|
||||||
|
async function GetSecret(username: string, password: string) {
|
||||||
|
return await Request('https://single_factor.example.com:8080/secret.html', {
|
||||||
|
auth: {
|
||||||
|
username,
|
||||||
|
password
|
||||||
|
},
|
||||||
|
rejectUnauthorized: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function() {
|
||||||
|
it("should retrieve secret when Authorization header is provided", async function() {
|
||||||
|
const res = await GetSecret('john', 'password');
|
||||||
|
if (res.indexOf('This is a very important secret!') < 0) {
|
||||||
|
throw new Error('Cannot access secret.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not retrieve secret when providing bad password", async function() {
|
||||||
|
const res = await GetSecret('john', 'bad-password');
|
||||||
|
if (res.indexOf('This is a very important secret!') >= 0) {
|
||||||
|
throw new Error('Cannot access secret.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not retrieve secret when authenticating with unexisting user", async function() {
|
||||||
|
const res = await GetSecret('dontexist', 'password');
|
||||||
|
if (res.indexOf('This is a very important secret!') >= 0) {
|
||||||
|
throw new Error('Cannot access secret.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
|
@ -30,5 +30,5 @@ export default function() {
|
||||||
|
|
||||||
// And the user should end up on the second factor page.
|
// And the user should end up on the second factor page.
|
||||||
await VerifyIsSecondFactorStage(this.driver);
|
await VerifyIsSecondFactorStage(this.driver);
|
||||||
})
|
});
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user