Skip to content

Commit

Permalink
Fix relay test
Browse files Browse the repository at this point in the history
  • Loading branch information
guimard committed Aug 16, 2024
1 parent 0efd65f commit d699506
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 12 deletions.
4 changes: 2 additions & 2 deletions portal/__test__/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM debian:bookworm-slim

RUN apt-get update && apt-get upgrade -y && apt-get install -y mocha node-supertest node-he node-express
RUN apt-get update && apt-get upgrade -y && apt-get install -y mocha node-supertest node-he

RUN mkdir /test

COPY *.test.js /test/

CMD [ "mocha", "-t", "30000", "/test/*.test.js" ]
CMD [ "mocha", "--exit", "-t", "30000", "/test/*.test.js" ]
15 changes: 14 additions & 1 deletion portal/__test__/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
version: "3.4"

services:
relay:
image: yadd/relay-test
build:
context: ./server
networks:
portaltest:
aliases:
- relay.example.com

auth.example.com:
container_name: test_portal_with_supertest
image: yadd/lemonldap-ng-portal
environment:
- LOGGER=stderr
- USERLOGGER=stderr
- "RELAY=foo.example.com=http://test:3000/"
- "RELAY=foo.example.com=http://relay.example.com:3000/"
depends_on:
relay:
condition: service_started
networks:
portaltest:
aliases:
- foo.example.com

test:
image: yadd/lemonldap-ng-portal-test
build:
Expand Down
10 changes: 1 addition & 9 deletions portal/__test__/portal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
const supertest = require('supertest');
const assert = require('assert');
const request = supertest.agent('http://auth.example.com');
const express = require('express');

const app = express();
app.get('/', function (req, res) {
res.status(200).json({ name: 'john' });
})
app.listen(3000)

describe('LLNG portal', () => {
before(function (done) {
Expand Down Expand Up @@ -62,10 +55,9 @@ describe('LLNG portal', () => {
})
describe('RELAY', () => {
const request = supertest.agent('http://foo.example.com')
it('should find /languages/fr.json', (done) => {
it('should find http://foo.example.com/', (done) => {
request.get('/')
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
.expect(200)
.then(res => {
expect(res.body.name).toEqual('john');
Expand Down
7 changes: 7 additions & 0 deletions portal/__test__/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM debian:bookworm-slim

RUN apt-get update && apt-get upgrade -y && apt-get install -y node-express

COPY index.js /

CMD ["node","/index.js"]
9 changes: 9 additions & 0 deletions portal/__test__/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/node

const express = require('express');

const app = express();
app.get('/', function (req, res) {
res.status(200).json({ name: 'john' });
})
app.listen(3000)
1 change: 1 addition & 0 deletions portal/clean
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh

docker rmi yadd/lemonldap-ng-portal-test
docker rmi yadd/relay-test

0 comments on commit d699506

Please sign in to comment.