diff --git a/scripts/authelia-scripts b/scripts/authelia-scripts index eab9e7b0..b6d8ad0f 100755 --- a/scripts/authelia-scripts +++ b/scripts/authelia-scripts @@ -12,6 +12,7 @@ program .command('test', 'Run Authelia integration tests.') .command('unittest', 'Run Authelia integration tests.') + .command('travis', 'Build and test Authelia on Travis.') .command('hash-password ', 'Hash a password with SSHA512.') .command('build-docker', 'Build Docker image containing production version of Authelia.') .command('publish-docker', 'Publish Docker image containing production version of Authelia to Dockerhub.') diff --git a/scripts/travis.sh b/scripts/authelia-scripts-travis similarity index 100% rename from scripts/travis.sh rename to scripts/authelia-scripts-travis diff --git a/server/src/lib/routes/firstfactor/post.spec.ts b/server/src/lib/routes/firstfactor/post.spec.ts index df376821..71244e5c 100644 --- a/server/src/lib/routes/firstfactor/post.spec.ts +++ b/server/src/lib/routes/firstfactor/post.spec.ts @@ -114,7 +114,7 @@ describe("routes/firstfactor/post", function () { Assert.equal(res.status.getCall(0).args[0], 200); Assert.equal(mocks.regulator.markStub.getCall(0).args[0], "username"); Assert.deepEqual(res.send.getCall(0).args[0], { - error: "Operation failed." + error: "Authentication failed. Please check your credentials." }); }); }); @@ -126,7 +126,7 @@ describe("routes/firstfactor/post", function () { .then(function () { Assert.equal(res.status.getCall(0).args[0], 200); Assert.deepEqual(res.send.getCall(0).args[0], { - error: "Operation failed." + error: "Authentication failed. Please check your credentials." }); }); }); diff --git a/server/src/lib/routes/firstfactor/post.ts b/server/src/lib/routes/firstfactor/post.ts index 2e879f78..7f252e6c 100644 --- a/server/src/lib/routes/firstfactor/post.ts +++ b/server/src/lib/routes/firstfactor/post.ts @@ -96,8 +96,8 @@ export default function (vars: ServerVariables) { }) .catch(AuthenticationError, function (err: Error) { vars.regulator.mark(username, false); - return ErrorReplies.replyWithError200(req, res, vars.logger, UserMessages.OPERATION_FAILED)(err); + return ErrorReplies.replyWithError200(req, res, vars.logger, UserMessages.AUTHENTICATION_FAILED)(err); }) - .catch(ErrorReplies.replyWithError200(req, res, vars.logger, UserMessages.OPERATION_FAILED)); + .catch(ErrorReplies.replyWithError200(req, res, vars.logger, UserMessages.AUTHENTICATION_FAILED)); }; } diff --git a/server/src/lib/routes/secondfactor/totp/sign/post.spec.ts b/server/src/lib/routes/secondfactor/totp/sign/post.spec.ts index 70a20d39..d0c29b70 100644 --- a/server/src/lib/routes/secondfactor/totp/sign/post.spec.ts +++ b/server/src/lib/routes/secondfactor/totp/sign/post.spec.ts @@ -67,7 +67,7 @@ describe("routes/secondfactor/totp/sign/post", function () { Assert.notEqual(authSession.authentication_level, Level.TWO_FACTOR); Assert.equal(res.status.getCall(0).args[0], 200); Assert.deepEqual(res.send.getCall(0).args[0], { - error: "Operation failed." + error: "Authentication failed. Have you already registered your secret?" }); return BluebirdPromise.resolve(); }); diff --git a/server/src/lib/routes/secondfactor/totp/sign/post.ts b/server/src/lib/routes/secondfactor/totp/sign/post.ts index 2da0cfad..0f379740 100644 --- a/server/src/lib/routes/secondfactor/totp/sign/post.ts +++ b/server/src/lib/routes/secondfactor/totp/sign/post.ts @@ -34,7 +34,7 @@ export default function (vars: ServerVariables) { return Bluebird.resolve(); }) .catch(ErrorReplies.replyWithError200(req, res, vars.logger, - UserMessages.OPERATION_FAILED)); + UserMessages.AUTHENTICATION_TOTP_FAILED)); } return handler; } diff --git a/test/helpers/assertions/VerifyForwardedHeaderIs.ts b/test/helpers/assertions/VerifyForwardedHeaderIs.ts index 2df8c6a5..95716d97 100644 --- a/test/helpers/assertions/VerifyForwardedHeaderIs.ts +++ b/test/helpers/assertions/VerifyForwardedHeaderIs.ts @@ -7,7 +7,6 @@ export default async function(driver: WebDriver, header: string, expectedValue: const text = await el.getText(); const expectedLine = Util.format("\"%s\": \"%s\"", header, expectedValue); - if (text.indexOf(expectedLine) < 0) { throw new Error("Header not found."); } diff --git a/test/helpers/behaviors/RegisterAndLoginTwoFactor.ts b/test/helpers/behaviors/RegisterAndLoginTwoFactor.ts index 2ea4cb22..49868673 100644 --- a/test/helpers/behaviors/RegisterAndLoginTwoFactor.ts +++ b/test/helpers/behaviors/RegisterAndLoginTwoFactor.ts @@ -1,6 +1,7 @@ import { WebDriver } from "selenium-webdriver"; import LoginAndRegisterTotp from "../LoginAndRegisterTotp"; import FullLogin from "../FullLogin"; +import VerifyUrlIs from "../assertions/VerifyUrlIs"; export default async function( driver: WebDriver, @@ -11,5 +12,6 @@ export default async function( const secret = await LoginAndRegisterTotp(driver, username, password, email); await FullLogin(driver, username, secret, targetUrl); + await VerifyUrlIs(driver, targetUrl); return secret; }; \ No newline at end of file diff --git a/test/helpers/context/AutheliaSuite.ts b/test/helpers/context/AutheliaSuite.ts index f407343c..53b62185 100644 --- a/test/helpers/context/AutheliaSuite.ts +++ b/test/helpers/context/AutheliaSuite.ts @@ -1,7 +1,4 @@ import WithAutheliaRunning from "./WithAutheliaRunning"; -import WithDriver from "./WithDriver"; - -let running = false; interface AutheliaSuiteType { (description: string, configPath: string, cb: (this: Mocha.ISuiteCallbackContext) => void): Mocha.ISuite; @@ -11,13 +8,11 @@ interface AutheliaSuiteType { function AutheliaSuiteBase(description: string, configPath: string, cb: (this: Mocha.ISuiteCallbackContext) => void, context: (description: string, ctx: (this: Mocha.ISuiteCallbackContext) => void) => Mocha.ISuite) { - if (!running && process.env['WITH_SERVER'] == 'y') { - console.log('Spawning Authelia server with configuration %s.', configPath); - WithAutheliaRunning(configPath); - running = true; - } - return context('Suite: ' + description, function(this: Mocha.ISuiteCallbackContext) { + if (process.env['WITH_SERVER'] == 'y') { + WithAutheliaRunning(configPath); + } + cb.call(this); }); } diff --git a/test/helpers/context/WithAutheliaRunning.ts b/test/helpers/context/WithAutheliaRunning.ts index 397681ef..2bf96b25 100644 --- a/test/helpers/context/WithAutheliaRunning.ts +++ b/test/helpers/context/WithAutheliaRunning.ts @@ -4,6 +4,8 @@ import ChildProcess from 'child_process'; export default function WithAutheliaRunning(configPath: string, waitTimeout: number = 3000) { before(function() { this.timeout(5000); + + console.log('Spawning Authelia server with configuration %s.', configPath); const authelia = ChildProcess.spawn( './scripts/authelia-scripts', ['serve', '--no-watch', '--config', configPath], @@ -21,6 +23,7 @@ export default function WithAutheliaRunning(configPath: string, waitTimeout: num after(function() { this.timeout(1000); + console.log('Killing Authelia server.'); // Kill the group of processes. process.kill(-this.authelia.pid); }); diff --git a/test/suites/complete/scenarii/AutheliaRestart.ts b/test/suites/complete/scenarii/AutheliaRestart.ts index 6a771cb9..c2cad8cb 100644 --- a/test/suites/complete/scenarii/AutheliaRestart.ts +++ b/test/suites/complete/scenarii/AutheliaRestart.ts @@ -32,8 +32,7 @@ export default function() { await GET_Expect502('https://login.example.com:8080/api/state'); await this.driver.sleep(1000); ChildProcess.execSync('rm .authelia-interrupt'); - await this.driver.sleep(1000); - + await this.driver.sleep(4000); await VisitPageAndWaitUrlIs(this.driver, 'https://admin.example.com:8080/secret.html'); await VerifySecretObserved(this.driver); @@ -63,7 +62,7 @@ export default function() { await GET_Expect502('https://login.example.com:8080/api/state'); await this.driver.sleep(1000); ChildProcess.execSync('rm .authelia-interrupt'); - await this.driver.sleep(1000); + await this.driver.sleep(4000); // The user can re-authenticate with the secret. await FullLogin(this.driver, 'john', this.secret, 'https://admin.example.com:8080/secret.html') diff --git a/test/suites/complete/scenarii/CustomHeadersForwarded.ts b/test/suites/complete/scenarii/CustomHeadersForwarded.ts index ddb3bf64..2fdc8d04 100644 --- a/test/suites/complete/scenarii/CustomHeadersForwarded.ts +++ b/test/suites/complete/scenarii/CustomHeadersForwarded.ts @@ -3,9 +3,10 @@ import { StartDriver, StopDriver } from "../../../helpers/context/WithDriver"; import RegisterAndLoginWith2FA from "../../../helpers/behaviors/RegisterAndLoginTwoFactor"; import VerifyForwardedHeaderIs from "../../../helpers/assertions/VerifyForwardedHeaderIs"; import LoginOneFactor from "../../../helpers/behaviors/LoginOneFactor"; +import VerifyUrlIs from "../../../helpers/assertions/VerifyUrlIs"; export default function() { - describe.only("Custom-Forwarded-User and Custom-Forwarded-Groups are correctly forwarded to protected backend", function() { + describe("Custom-Forwarded-User and Custom-Forwarded-Groups are correctly forwarded to protected backend", function() { this.timeout(10000); describe("With single factor", function() {