mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
Adding one integration test for redis
This commit is contained in:
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']
|
||||
},
|
||||
"test": {
|
||||
cmd: "npm",
|
||||
args: ['run', 'test']
|
||||
cmd: "./node_modules/.bin/mocha",
|
||||
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": {
|
||||
cmd: "docker",
|
||||
args: ['build', '-t', 'clems4ever/authelia', '.']
|
||||
},
|
||||
"docker-restart": {
|
||||
cmd: "docker-compose",
|
||||
args: ['-f', 'docker-compose.yml', '-f', 'docker-compose.dev.yml', 'restart', 'auth']
|
||||
cmd: "./scripts/dc-example.sh",
|
||||
args: ['up', '-d']
|
||||
},
|
||||
"minify": {
|
||||
cmd: "./node_modules/.bin/uglifyjs",
|
||||
|
|
|
@ -6,10 +6,7 @@ services:
|
|||
volumes:
|
||||
- ./config.template.yml:/etc/authelia/config.yml:ro
|
||||
- ./notifications:/var/lib/authelia/notifications
|
||||
networks:
|
||||
- example-network
|
||||
|
||||
redis:
|
||||
image: redis
|
||||
depends_on:
|
||||
- redis
|
||||
networks:
|
||||
- example-network
|
||||
|
|
6
example/redis/docker-compose.yml
Normal file
6
example/redis/docker-compose.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
version: '2'
|
||||
services:
|
||||
redis:
|
||||
image: redis
|
||||
networks:
|
||||
- example-network
|
|
@ -7,7 +7,7 @@
|
|||
"authelia": "dist/src/server/index.js"
|
||||
},
|
||||
"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",
|
||||
"serve": "node dist/server/index.js"
|
||||
},
|
||||
|
@ -61,7 +61,7 @@
|
|||
"@types/proxyquire": "^1.3.27",
|
||||
"@types/query-string": "^4.3.1",
|
||||
"@types/randomstring": "^1.1.5",
|
||||
"@types/request": "0.0.45",
|
||||
"@types/request": "0.0.46",
|
||||
"@types/sinon": "^2.2.1",
|
||||
"@types/speakeasy": "^2.0.1",
|
||||
"@types/tmp": "0.0.33",
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
docker ps -a
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ if (!configurationFilepath) {
|
|||
|
||||
console.log("Parse configuration file: %s", configurationFilepath);
|
||||
|
||||
const yaml_config = YAML.load(configurationFilepath);
|
||||
const yamlContent = YAML.load(configurationFilepath);
|
||||
|
||||
const deps: GlobalDependencies = {
|
||||
u2f: require("u2f"),
|
||||
|
@ -29,7 +29,7 @@ const deps: GlobalDependencies = {
|
|||
};
|
||||
|
||||
const server = new Server();
|
||||
server.start(yaml_config, deps)
|
||||
server.start(yamlContent, deps)
|
||||
.then(() => {
|
||||
console.log("The server is started!");
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ import { GlobalDependencies } from "../../types/Dependencies";
|
|||
import { AuthenticationRegulator } from "./AuthenticationRegulator";
|
||||
import UserDataStore from "./UserDataStore";
|
||||
import ConfigurationAdapter from "./ConfigurationAdapter";
|
||||
import { TOTPValidator } from "./TOTPValidator";
|
||||
import { TOTPValidator } from "./TOTPValidator";
|
||||
import { TOTPGenerator } from "./TOTPGenerator";
|
||||
import RestApi from "./RestApi";
|
||||
import { LdapClient } from "./LdapClient";
|
||||
|
@ -42,6 +42,8 @@ export default class Server {
|
|||
// by default the level of logs is info
|
||||
deps.winston.level = config.logs_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));
|
||||
|
||||
ServerVariables.fill(app, config, deps);
|
||||
|
|
|
@ -2,4 +2,3 @@ FROM node:7-alpine
|
|||
|
||||
WORKDIR /usr/src
|
||||
|
||||
CMD ["./node_modules/.bin/mocha", "--compilers", "ts:ts-node/register", "--recursive", "test/integration"]
|
||||
|
|
|
@ -73,6 +73,9 @@ session:
|
|||
secret: unsecure_secret
|
||||
expiration: 3600000
|
||||
domain: test.local
|
||||
redis:
|
||||
host: redis
|
||||
port: 6379
|
||||
|
||||
|
||||
# The directory where the DB files will be saved
|
||||
|
|
|
@ -11,6 +11,7 @@ services:
|
|||
|
||||
int-test:
|
||||
build: ./test/integration
|
||||
command: ./node_modules/.bin/mocha --compilers ts:ts-node/register --recursive test/integration
|
||||
volumes:
|
||||
- ./:/usr/src
|
||||
networks:
|
||||
|
|
23
test/integration/redis.test.ts
Normal file
23
test/integration/redis.test.ts
Normal file
|
@ -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
Block a user