Skip to content

Commit

Permalink
Add CI config load test (#2)
Browse files Browse the repository at this point in the history
Closed #1 

* Added CI config load test
  • Loading branch information
pmanko authored Dec 7, 2021
1 parent 288951d commit 073eca3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Publish Docker image

on:
pull_request:
branches: [ main ]
push:
branches: [ 'main' ]
branches: [ main ]
release:
types: [ 'published' ]
types: [published]
workflow_dispatch:

env:
Expand All @@ -26,6 +28,22 @@ jobs:
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: false
load: true
tags: test-image:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Boot up containers
run: docker-compose up -d openhim-core mongo-db

- name: Load test config
run: docker-compose up --exit-code-from openhim-config openhim-config

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ ADD package.json /app/
ADD yarn.lock /app/
ADD docker-entrypoint.sh /app/
ADD load-openhim-config.js /app/
ADD auth.js /app/
ADD test-openhim-config-template.json /app/test-openhim-config.json

RUN chmod u+x docker-entrypoint.sh load-openhim-config.js
RUN chmod u+x docker-entrypoint.sh load-openhim-config.js auth.js

RUN yarn

ENV API_URL='https://openhim-core:8080'
ENV INITIAL_PW='openhim-password'
ENV ADMIN_PW='openhim'
ENV ODE_TLS_REJECT_UNAUTHORIZED=0

ENTRYPOINT ./docker-entrypoint.sh
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# openhim-config

[![Publish Docker image](https://github.com/I-TECH-UW/openhim-config/actions/workflows/publish.yml/badge.svg)](https://github.com/I-TECH-UW/openhim-config/actions/workflows/publish.yml)
[![CI](https://github.com/I-TECH-UW/openhim-config/actions/workflows/publish.yml/badge.svg)](https://github.com/I-TECH-UW/openhim-config/actions/workflows/publish.yml)

Dockerized utility for loading default configuration into a new instance of OpenHIM

See [workflows](https://github.com/I-TECH-UW/openhim-config/actions/workflows/publish.yml) for example use.
12 changes: 8 additions & 4 deletions auth.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
const crypto = require('crypto')
const got = require('got');

// Generate the relevant auth headers
export const genAuthSettings = async (options) => {
exports.genAuthSettings = async (options) => {
let urn = new URL(options.url);

let authResponse = await got.get(`${urn.protocol}//${urn.host}/authenticate/${options.user}`, { https: { rejectUnauthorized: options.rejectUnauthorized } }).json()
console.log("Generating Auth Settings:"+JSON.stringify(options))

let authResponse = await got.get(`${urn.protocol}//${urn.host}/authenticate/${options.user}`, { https: { rejectUnauthorized: false, requestCert: false } }).json()
const salt = authResponse.salt

// create passhash
Expand All @@ -20,10 +23,11 @@ export const genAuthSettings = async (options) => {
}
}

export const getAuthHeader = async(url, user, pw, rua) => {
exports.getAuthHeader = async(url, user, pw, rua) => {
let urn = new URL(url);

let authResponse = await got.get(`${urn.protocol}//${urn.host}/authenticate/${user}`, { https: { rejectUnauthorized: rua } }).json()
console.log("Getting auth header")
let authResponse = await got.get(`${urn.protocol}//${urn.host}/authenticate/${user}`, { https: { rejectUnauthorized: false, agent: false, requestCert: true } }).json()
const salt = authResponse.salt;

let shasum = crypto.createHash('sha512');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openhim-config",
"version": "0.1.0",
"version": "0.1.1",
"description": "Default Configuration loaded for OpenHIM CI Instances",
"main": "load-openhim-config.js",
"repository": "https://github.com/I-TECH-UW/openhim-config.git",
Expand Down

0 comments on commit 073eca3

Please sign in to comment.