diff --git a/portal/__test__/Dockerfile b/portal/__test__/Dockerfile index a28f16a..6984468 100644 --- a/portal/__test__/Dockerfile +++ b/portal/__test__/Dockerfile @@ -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" ] diff --git a/portal/__test__/docker-compose.yml b/portal/__test__/docker-compose.yml index 4dc69cc..49f5066 100644 --- a/portal/__test__/docker-compose.yml +++ b/portal/__test__/docker-compose.yml @@ -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: diff --git a/portal/__test__/portal.test.js b/portal/__test__/portal.test.js index aaa89be..bbbab12 100755 --- a/portal/__test__/portal.test.js +++ b/portal/__test__/portal.test.js @@ -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) { @@ -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'); diff --git a/portal/__test__/server/Dockerfile b/portal/__test__/server/Dockerfile new file mode 100644 index 0000000..f815c74 --- /dev/null +++ b/portal/__test__/server/Dockerfile @@ -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"] diff --git a/portal/__test__/server/index.js b/portal/__test__/server/index.js new file mode 100644 index 0000000..379f9fd --- /dev/null +++ b/portal/__test__/server/index.js @@ -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) diff --git a/portal/clean b/portal/clean index 1e8860c..639de2a 100755 --- a/portal/clean +++ b/portal/clean @@ -1,3 +1,4 @@ #!/bin/sh docker rmi yadd/lemonldap-ng-portal-test +docker rmi yadd/relay-test