Skip to content

Commit

Permalink
Merge pull request #44 from EGA-archive/feature/external-images
Browse files Browse the repository at this point in the history
Feature/external images
  • Loading branch information
silverdaz committed Mar 26, 2019
2 parents ab597f0 + 084f005 commit d4d742f
Show file tree
Hide file tree
Showing 19 changed files with 131 additions and 975 deletions.
70 changes: 11 additions & 59 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,31 @@ git:
quiet: true

stages:
- name: preflight
- name: tests
if: type = pull_request
- name: images
if: type = pull_request AND branch = master

jobs:
include:
#
# Unit Tests and Image Build
#
- stage: preflight
- stage: tests
name: "Unit Tests"
python: 3.6
before_script: pip install tox-travis
script: tox
- stage: preflight
if: type = pull_request
services: docker
name: "Images build"
before_script:
- pip install tox-travis
- cd deploy/images
# Pulling image for layer caching
- make -j 2 pull-base IMGTAG=latest
script:
- make -j 4 base unit-tests
- make -j 2 push-base
#
# BATS Tests
#
- stage: tests
name: "Integration Tests"
if: type = pull_request
services: docker
before_script:
- pip3 install -r requirements.txt
- git clone https://github.com/bats-core/bats-core.git
- pushd bats-core && git checkout v1.1.0 && sudo ./install.sh /usr/local && popd
- cd deploy
- make -C images -j 2 pull-base
- make -C images -j 2 retag-base
- make -C images
- make prepare
- make bootstrap ARGS="--keyserver ega"
- sudo chown -R travis private
Expand All @@ -61,14 +45,14 @@ jobs:
- bats integration
- stage: tests
name: "Robustness Tests"
if: type = pull_request
services: docker
before_script:
- pip3 install -r requirements.txt
- git clone https://github.com/bats-core/bats-core.git
- pushd bats-core && git checkout v1.1.0 && sudo ./install.sh /usr/local && popd
- cd deploy
- make -C images -j 2 pull-base
- make -C images -j 2 retag-base
- make -C images
- make prepare
- make bootstrap ARGS="--keyserver ega"
- sudo chown -R travis private
Expand All @@ -77,20 +61,16 @@ jobs:
script:
- cd ../tests
- bats robustness
- stage: tests
name: "Stress Tests"
services: docker
script: echo "Stress Tests.... hmm... later"
- stage: tests
name: "Security Tests"
if: type = pull_request
services: docker
before_script:
- pip3 install -r requirements.txt
- git clone https://github.com/bats-core/bats-core.git
- pushd bats-core && git checkout v1.1.0 && sudo ./install.sh /usr/local && popd
- cd deploy
- make -C images -j 2 pull-base
- make -C images -j 2 retag-base
- make -C images
- make prepare
- make bootstrap ARGS="--keyserver ega"
- sudo chown -R travis private
Expand All @@ -104,11 +84,11 @@ jobs:
#
- stage: tests
name: "Cucumber Ingestion Tests"
if: type = pull_request
before_script:
- pip3 install -r requirements.txt
- cd deploy
- make -C images -j 2 pull-base
- make -C images -j 2 retag-base
- make -C images
- make prepare
- make bootstrap ARGS='--inbox mina --keyserver ega'
- sudo chown -R travis private
Expand All @@ -117,28 +97,13 @@ jobs:
script:
- cd tests
- mvn test -Dtest=IngestionTests
- stage: tests
name: "Cucumber Outgestion Tests"
before_script:
- pip3 install -r requirements.txt
- cd deploy
- make -C images -j 2 pull-base
- make -C images -j 2 retag-base
- make prepare
- make bootstrap ARGS='--inbox mina --keyserver ega'
- sudo chown -R travis private
- make up
- make preflight-check
script:
- cd tests
- mvn test -Dtest=OutgestionTests
- stage: tests
name: "Cucumber Robustness Tests"
if: type = pull_request
before_script:
- pip3 install -r requirements.txt
- cd deploy
- make -C images -j 2 pull-base
- make -C images -j 2 retag-base
- make -C images
- make prepare
- make bootstrap ARGS='--inbox mina --keyserver ega'
- sudo chown -R travis private
Expand All @@ -147,19 +112,6 @@ jobs:
script:
- cd tests
- mvn test -Dtest=RobustnessTests
#
# Retagging the images
#
- stage: images
services: docker
name: "Images Retag"
before_script:
- cd deploy/images
script:
- make -j 2 pull-base
- make retag-base
- make -j 2 push-base IMGTAG=latest
- make clean-tag-base


notifications:
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions deploy/bootstrap/defs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ function generate_password {
${PYTHONEXEC} -c "import secrets,string;print(''.join(secrets.choice(string.ascii_letters + string.digits) for i in range(${size})))"
}

function generate_mq_hash {
local pass=${1}
[[ -n $1 ]] || { echo 'Missing argument' 1>&2; exit 1; } # fail
${PYTHONEXEC} $HERE/mq_hash.py "$1"
}
36 changes: 36 additions & 0 deletions deploy/bootstrap/mq_hash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'''Creating a rabbitmq hash of a supplied password'''

import sys
import os
from base64 import b64encode
import hashlib

# inspired by https://gist.github.com/komuw/c6fb1a1c757afb43fe69bdd736d5cf63
def hash_pass(password):
"""Hashing password according to RabbitMQ specs."""
# 1.Generate a random 32 bit salt:
# This will generate 32 bits of random data:
salt = os.urandom(4)

# 2.Concatenate that with the UTF-8 representation of the password (in this case "simon")
tmp0 = salt + password.encode('utf-8')

# 3. Take the SHA256 hash and get the bytes back
tmp1 = hashlib.sha256(tmp0).digest()

# 4. Concatenate the salt again:
salted_hash = salt + tmp1

# 5. convert to base64 encoding:
pass_hash = b64encode(salted_hash).decode("utf-8")

return pass_hash


if __name__ == '__main__':

if len(sys.argv) > 1:
print(hash_pass(sys.argv[1]))
else:
password = input()
print(hash_pass(password.strip()))

0 comments on commit d4d742f

Please sign in to comment.