Adding one integration test for redis
parent
94f5a1f256
commit
f516aaf243
12
Gruntfile.js
12
Gruntfile.js
|
@ -13,16 +13,20 @@ module.exports = function (grunt) {
|
||||||
args: ['-c', 'tslint.json', '-p', 'tsconfig.json']
|
args: ['-c', 'tslint.json', '-p', 'tsconfig.json']
|
||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
cmd: "npm",
|
cmd: "./node_modules/.bin/mocha",
|
||||||
args: ['run', 'test']
|
args: ['--compilers', 'ts:ts-node/register', '--recursive', 'test/client', 'test/server']
|
||||||
|
},
|
||||||
|
"test-int": {
|
||||||
|
cmd: "./node_modules/.bin/mocha",
|
||||||
|
args: ['--compilers', 'ts:ts-node/register', '--recursive', 'test/integration']
|
||||||
},
|
},
|
||||||
"docker-build": {
|
"docker-build": {
|
||||||
cmd: "docker",
|
cmd: "docker",
|
||||||
args: ['build', '-t', 'clems4ever/authelia', '.']
|
args: ['build', '-t', 'clems4ever/authelia', '.']
|
||||||
},
|
},
|
||||||
"docker-restart": {
|
"docker-restart": {
|
||||||
cmd: "docker-compose",
|
cmd: "./scripts/dc-example.sh",
|
||||||
args: ['-f', 'docker-compose.yml', '-f', 'docker-compose.dev.yml', 'restart', 'auth']
|
args: ['up', '-d']
|
||||||
},
|
},
|
||||||
"minify": {
|
"minify": {
|
||||||
cmd: "./node_modules/.bin/uglifyjs",
|
cmd: "./node_modules/.bin/uglifyjs",
|
||||||
|
|
|
@ -6,10 +6,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- ./config.template.yml:/etc/authelia/config.yml:ro
|
- ./config.template.yml:/etc/authelia/config.yml:ro
|
||||||
- ./notifications:/var/lib/authelia/notifications
|
- ./notifications:/var/lib/authelia/notifications
|
||||||
networks:
|
depends_on:
|
||||||
- example-network
|
- redis
|
||||||
|
|
||||||
redis:
|
|
||||||
image: redis
|
|
||||||
networks:
|
networks:
|
||||||
- example-network
|
- example-network
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
redis:
|
||||||
|
image: redis
|
||||||
|
networks:
|
||||||
|
- example-network
|
|
@ -7,7 +7,7 @@
|
||||||
"authelia": "dist/src/server/index.js"
|
"authelia": "dist/src/server/index.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "./node_modules/.bin/mocha --compilers ts:ts-node/register --recursive test/client test/server",
|
"test": "./node_modules/.bin/grunt test",
|
||||||
"cover": "NODE_ENV=test nyc npm t",
|
"cover": "NODE_ENV=test nyc npm t",
|
||||||
"serve": "node dist/server/index.js"
|
"serve": "node dist/server/index.js"
|
||||||
},
|
},
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
"@types/proxyquire": "^1.3.27",
|
"@types/proxyquire": "^1.3.27",
|
||||||
"@types/query-string": "^4.3.1",
|
"@types/query-string": "^4.3.1",
|
||||||
"@types/randomstring": "^1.1.5",
|
"@types/randomstring": "^1.1.5",
|
||||||
"@types/request": "0.0.45",
|
"@types/request": "0.0.46",
|
||||||
"@types/sinon": "^2.2.1",
|
"@types/sinon": "^2.2.1",
|
||||||
"@types/speakeasy": "^2.0.1",
|
"@types/speakeasy": "^2.0.1",
|
||||||
"@types/tmp": "0.0.33",
|
"@types/tmp": "0.0.33",
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
docker-compose -f docker-compose.base.yml -f docker-compose.yml -f example/nginx/docker-compose.yml -f example/ldap/docker-compose.yml $*
|
docker-compose -f docker-compose.base.yml -f docker-compose.yml -f example/redis/docker-compose.yml -f example/nginx/docker-compose.yml -f example/ldap/docker-compose.yml $*
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
docker-compose -f docker-compose.base.yml -f example/ldap/docker-compose.yml -f test/integration/docker-compose.yml $*
|
docker-compose -f docker-compose.base.yml -f example/redis/docker-compose.yml -f example/ldap/docker-compose.yml -f test/integration/docker-compose.yml $*
|
||||||
|
|
|
@ -6,7 +6,9 @@ echo "Build services images..."
|
||||||
./scripts/dc-test.sh build
|
./scripts/dc-test.sh build
|
||||||
|
|
||||||
echo "Start services..."
|
echo "Start services..."
|
||||||
./scripts/dc-test.sh up -d authelia nginx openldap
|
./scripts/dc-test.sh up -d redis openldap
|
||||||
|
sleep 2
|
||||||
|
./scripts/dc-test.sh up -d authelia nginx
|
||||||
sleep 3
|
sleep 3
|
||||||
docker ps -a
|
docker ps -a
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ if (!configurationFilepath) {
|
||||||
|
|
||||||
console.log("Parse configuration file: %s", configurationFilepath);
|
console.log("Parse configuration file: %s", configurationFilepath);
|
||||||
|
|
||||||
const yaml_config = YAML.load(configurationFilepath);
|
const yamlContent = YAML.load(configurationFilepath);
|
||||||
|
|
||||||
const deps: GlobalDependencies = {
|
const deps: GlobalDependencies = {
|
||||||
u2f: require("u2f"),
|
u2f: require("u2f"),
|
||||||
|
@ -29,7 +29,7 @@ const deps: GlobalDependencies = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = new Server();
|
const server = new Server();
|
||||||
server.start(yaml_config, deps)
|
server.start(yamlContent, deps)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log("The server is started!");
|
console.log("The server is started!");
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { GlobalDependencies } from "../../types/Dependencies";
|
||||||
import { AuthenticationRegulator } from "./AuthenticationRegulator";
|
import { AuthenticationRegulator } from "./AuthenticationRegulator";
|
||||||
import UserDataStore from "./UserDataStore";
|
import UserDataStore from "./UserDataStore";
|
||||||
import ConfigurationAdapter from "./ConfigurationAdapter";
|
import ConfigurationAdapter from "./ConfigurationAdapter";
|
||||||
import { TOTPValidator } from "./TOTPValidator";
|
import { TOTPValidator } from "./TOTPValidator";
|
||||||
import { TOTPGenerator } from "./TOTPGenerator";
|
import { TOTPGenerator } from "./TOTPGenerator";
|
||||||
import RestApi from "./RestApi";
|
import RestApi from "./RestApi";
|
||||||
import { LdapClient } from "./LdapClient";
|
import { LdapClient } from "./LdapClient";
|
||||||
|
@ -42,6 +42,8 @@ export default class Server {
|
||||||
// by default the level of logs is info
|
// by default the level of logs is info
|
||||||
deps.winston.level = config.logs_level;
|
deps.winston.level = config.logs_level;
|
||||||
console.log("Log level = ", deps.winston.level);
|
console.log("Log level = ", deps.winston.level);
|
||||||
|
|
||||||
|
deps.winston.debug("Content of YAML configuration file is %s", JSON.stringify(yamlConfiguration, undefined, 2));
|
||||||
deps.winston.debug("Authelia configuration is %s", JSON.stringify(config, undefined, 2));
|
deps.winston.debug("Authelia configuration is %s", JSON.stringify(config, undefined, 2));
|
||||||
|
|
||||||
ServerVariables.fill(app, config, deps);
|
ServerVariables.fill(app, config, deps);
|
||||||
|
|
|
@ -2,4 +2,3 @@ FROM node:7-alpine
|
||||||
|
|
||||||
WORKDIR /usr/src
|
WORKDIR /usr/src
|
||||||
|
|
||||||
CMD ["./node_modules/.bin/mocha", "--compilers", "ts:ts-node/register", "--recursive", "test/integration"]
|
|
||||||
|
|
|
@ -73,6 +73,9 @@ session:
|
||||||
secret: unsecure_secret
|
secret: unsecure_secret
|
||||||
expiration: 3600000
|
expiration: 3600000
|
||||||
domain: test.local
|
domain: test.local
|
||||||
|
redis:
|
||||||
|
host: redis
|
||||||
|
port: 6379
|
||||||
|
|
||||||
|
|
||||||
# The directory where the DB files will be saved
|
# The directory where the DB files will be saved
|
||||||
|
|
|
@ -11,6 +11,7 @@ services:
|
||||||
|
|
||||||
int-test:
|
int-test:
|
||||||
build: ./test/integration
|
build: ./test/integration
|
||||||
|
command: ./node_modules/.bin/mocha --compilers ts:ts-node/register --recursive test/integration
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/usr/src
|
- ./:/usr/src
|
||||||
networks:
|
networks:
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
|
||||||
|
import Redis = require("redis");
|
||||||
|
import Assert = require("assert");
|
||||||
|
|
||||||
|
const redisOptions = {
|
||||||
|
host: "redis",
|
||||||
|
port: 6379
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("test redis is correctly used", function () {
|
||||||
|
let redisClient: Redis.RedisClient;
|
||||||
|
|
||||||
|
before(function () {
|
||||||
|
redisClient = Redis.createClient(redisOptions);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should have registered at least one session", function (done) {
|
||||||
|
redisClient.dbsize(function (err: Error, count: number) {
|
||||||
|
Assert.equal(1, count);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue