Skip to content

Commit

Permalink
e2e and circleci added (Soluto#9)
Browse files Browse the repository at this point in the history
* e2e and circleci added

* circleci status badge added

* fix

* indent fix

* ..

* PR CR changes
  • Loading branch information
AleF83 authored and tomeresk committed Jul 23, 2019
1 parent fbf2876 commit f00c67c
Show file tree
Hide file tree
Showing 81 changed files with 1,976 additions and 0 deletions.
133 changes: 133 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
version: 2.1

commands:
build_image:
description: Builds image
parameters:
imageName:
type: string
workingDirectory:
type: string

steps:
- checkout
- run:
name: Build image
working_directory: << parameters.workingDirectory >>
command: docker build -t soluto/<< parameters.imageName >> --build-arg target=PRODUCTION .

- run:
name: Save image to fs
working_directory: /tmp
command: |
mkdir -p oidc-server-mock
docker save -o oidc-server-mock/<< parameters.imageName >>.tar soluto/<< parameters.imageName >>
- persist_to_workspace:
root: /tmp/oidc-server-mock
paths:
- << parameters.imageName >>.tar

push_image:
description: Push image to Docker Hub
parameters:
imageName:
type: string

steps:
- checkout

- attach_workspace:
at: /tmp/oidc-server-mock

- run:
name: Load Docker image
command: docker load < /tmp/oidc-server-mock<< parameters.imageName >>.tar


- run:
name: Set tag to env
command: echo 'export IMAGE_TAG=`echo "$CIRCLE_TAG" | cut -d'v' -f 2`' >> $BASH_ENV

- deploy:
name: Tag and push versioned Docker image
command: |
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
docker tag soluto/<< parameters.imageName >> soluto/<< parameters.imageName >>:${IMAGE_TAG}
docker push soluto/<< parameters.imageName >>:${IMAGE_TAG}
- deploy:
name: Tag and push latest Docker image
command: |
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
docker tag soluto/<< parameters.imageName >>:${IMAGE_TAG} soluto/<< parameters.imageName >>:lastest
docker push soluto/<< parameters.imageName >>:latest
jobs:
build_oidc_server_mock:
machine:
image: ubuntu-1604:201903-01

steps:
- build_image:
imageName: oidc-server-mock
workingDirectory: ./src

build_e2e:
machine:
image: ubuntu-1604:201903-01

steps:
- build_image:
imageName: e2e
workingDirectory: ./e2e

run_tests:
machine:
image: ubuntu-1604:201903-01

steps:
- checkout

- attach_workspace:
at: /tmp/oidc-server-mock

- run:
name: Load docker images from fs
working_directory: /tmp/oidc-server-mock
command: |
docker load < oidc-server-mock.tar
docker load < e2e.tar
- run:
name: Run E2E tests
working_directory: e2e
command: scripts/run_tests.sh

push_oidc_server_mock:
machine:
image: ubuntu-1604:201903-01

steps:
- push_image:
imageName: oidc-server-mock

workflows:
version: 2

build_test_push:
jobs:
- build_oidc_server_mock
- build_e2e
- run_tests:
requires:
- build_oidc_server_mock
- build_e2e
- push_oidc_server_mock:
requires:
- run_tests
filters:
branches:
only: master
tags:
only: /^v([0-9]+\.){2}[0-9]+(-\S+)?$/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# OpenId Connect Server Mock

[![CircleCI](https://circleci.com/gh/Soluto/oidc-server-mock.svg?style=svg)](https://circleci.com/gh/Soluto/oidc-server-mock)

This project allows you to run configurable mock server with OpenId Connect functionality.

This is the sample of using the server in `docker-compose` configuration:
Expand Down
2 changes: 2 additions & 0 deletions e2e/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
Dockerfile
83 changes: 83 additions & 0 deletions e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
dist
.DS_Store

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/
7 changes: 7 additions & 0 deletions e2e/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:10-alpine

COPY package.json yarn.lock ./
RUN yarn
COPY ./tests ./tests

CMD yarn test
25 changes: 25 additions & 0 deletions e2e/kubernetes/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: batch/v1
kind: Job
metadata:
name: e2e
labels:
name: e2e
app: e2e
spec:
template:
spec:
restartPolicy: Never
containers:
- name: e2e
image: soluto/e2e
imagePullPolicy: Never
env:
- name: OIDC_TOKEN_URL
value: http://oidc-server-mock/connect/token
- name: CLIENT_CREDENTIALS_CLIENT_ID
value: e2e-client-id
- name: CLIENT_CREDENTIALS_CLIENT_SECRET
value: e2e-client-secret
- name: API_RESOURCE
value: user-service-scope
backoffLimit: 0
57 changes: 57 additions & 0 deletions e2e/kubernetes/oidc-server-mock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: oidc-server-mock
spec:
selector:
matchLabels:
app: oidc-server-mock
template:
metadata:
labels:
app: oidc-server-mock
spec:
containers:
- name: oidc-server-mock
image: soluto/oidc-server-mock
imagePullPolicy: Never
env:
- name: API_RESOURCES_INLINE
value: |
[
"user-service-scope"
]
- name: CLIENTS_CONFIGURATION_INLINE
value: |
[
{
"ClientId": "e2e-client-id",
"ClientSecrets": [
"e2e-client-secret"
],
"Description": "e2e configuration",
"AllowedGrantTypes": [
"client_credentials"
],
"AllowedScopes": [
"user-service-scope"
]
}
]
livenessProbe:
httpGet:
path: /.well-known/openid-configuration
port: 80
---
kind: Service
apiVersion: v1
metadata:
name: oidc-server-mock
spec:
selector:
app: oidc-server-mock
ports:
- name: http
port: 80
targetPort: 80
---
23 changes: 23 additions & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "e2e",
"version": "1.0.0",
"scripts": {
"test": "mocha --require ts-node/register ./**/*.spec.ts --exit"
},
"license": "MIT",
"dependencies": {
"axios": "0.19.0",
"chai": "4.2.0",
"querystring": "0.2.0",
"wait-on": "3.3.0"
},
"devDependencies": {
"@types/chai": "4.1.7",
"@types/mocha": "5.2.7",
"@types/node": "12.6.8",
"mocha": "6.2.0",
"ts-node": "8.3.0",
"tslint": "5.18.0",
"typescript": "3.5.3"
}
}
Loading

0 comments on commit f00c67c

Please sign in to comment.