From 911123154546ad73299ea223f7d5c6de71453282 Mon Sep 17 00:00:00 2001 From: Cory Bennett Date: Wed, 3 Aug 2016 00:13:53 -0700 Subject: [PATCH] start adding some basic integration tests --- t/.jira.d/config.yml | 2 + t/000setup.t | 14 +++++ t/010login.t | 21 +++++++ t/100create.t | 132 +++++++++++++++++++++++++++++++++++++++++++ t/Dockerfile.inc | 3 + t/Dockerfile.pre | 3 + t/README.md | 67 ++++++++++++++++++++++ 7 files changed, 242 insertions(+) create mode 100644 t/.jira.d/config.yml create mode 100755 t/000setup.t create mode 100755 t/010login.t create mode 100755 t/100create.t create mode 100644 t/Dockerfile.inc create mode 100644 t/Dockerfile.pre create mode 100644 t/README.md diff --git a/t/.jira.d/config.yml b/t/.jira.d/config.yml new file mode 100644 index 0000000..176a554 --- /dev/null +++ b/t/.jira.d/config.yml @@ -0,0 +1,2 @@ +endpoint: http://localhost:8080 +user: gojira \ No newline at end of file diff --git a/t/000setup.t b/t/000setup.t new file mode 100755 index 0000000..3c53ca3 --- /dev/null +++ b/t/000setup.t @@ -0,0 +1,14 @@ +#!/bin/bash +eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)" +cd $(dirname $0) +jira=../jira + +PLAN 4 + +RUNS sh -c "docker rm -f go-jira-test || true" + +RUNS docker run --detach --name go-jira-test --publish 8080:8080 go-jira-test:latest + +RUNS sleep 10 + +RUNS curl -q -L --retry 60 --retry-delay 1 -f -s "http://localhost:8080/rest/api/2/serverInfo?doHealthCheck=1" diff --git a/t/010login.t b/t/010login.t new file mode 100755 index 0000000..19c4c00 --- /dev/null +++ b/t/010login.t @@ -0,0 +1,21 @@ +#!/bin/bash +eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)" +cd $(dirname $0) +jira=../jira + +PLAN 7 + +RUNS $jira logout + +NRUNS $jira req /rest/auth/1/session > /var/atlassian/jira/jira-config.properties \ No newline at end of file diff --git a/t/Dockerfile.pre b/t/Dockerfile.pre new file mode 100644 index 0000000..23cd4c6 --- /dev/null +++ b/t/Dockerfile.pre @@ -0,0 +1,3 @@ +INCLUDE MERGE -VOLUME -COPY \ + https://raw.githubusercontent.com/cptactionhank/docker-atlassian-jira-software/master/Dockerfile \ + Dockerfile.inc \ No newline at end of file diff --git a/t/README.md b/t/README.md new file mode 100644 index 0000000..cea4c1c --- /dev/null +++ b/t/README.md @@ -0,0 +1,67 @@ +## Setup +These tests assume there is a jira service running at 127.0.0.1:8080 with user "gojira" and password "gojira123". +There should also be a poweruser "admin" with password "admin123" + +The test Jira was setup following the instructions (here)[https://github.com/cptactionhank/docker-atlassian-jira]. + + +### build base docker image +``` +docker run --rm -i -v $(pwd):/root:ro coryb/dfpp Dockerfile.pre | docker build -t go-jira-base:latest - +``` + +### Initialize container +``` +docker run --detach --name go-jira-test --publish 8080:8080 go-jira-base:latest +``` + +### create admin user +``` +open http://localhost:8080 +``` +Then follow UI workflow to create "admin" user, skip intro and project creation. + +### Create gojira user +``` +jira req --user admin -M POST /rest/api/2/user '{"name":"gojira","password":"gojira123","emailAddress":"gojira@example.com","displayName":"Go Jira"}' +``` + +### Initialize new projects +``` +jira req --user admin -M POST /rest/api/2/project '{"key":"SCRUM","name":"Scrum","projectTypeKey":"software","projectTemplateKey":"com.pyxis.greenhopper.jira:gh-scrum-template","lead":"gojira"}' +jira req --user admin -M POST /rest/api/2/project '{"key":"KANBAN","name":"Kanban","projectTypeKey":"software","projectTemplateKey":"com.pyxis.greenhopper.jira:gh-kanban-template","lead":"gojira"}' +jira req --user admin -M POST /rest/api/2/project '{"key":"BASIC","name":"Basic","projectTypeKey":"software","projectTemplateKey":"com.pyxis.greenhopper.jira:basic-software-development-template","lead":"gojira"}' + +jira req --user admin -M POST /rest/api/2/project '{"key":"PROJECT","name":"Project","projectTypeKey":"business","projectTemplateKey":"com.atlassian.jira-core-project-templates:jira-core-project-management","lead":"gojira"}' +jira req --user admin -M POST /rest/api/2/project '{"key":"PROCESS","name":"Process","projectTypeKey":"business","projectTemplateKey":"com.atlassian.jira-core-project-templates:jira-core-process-management","lead":"gojira"}' +jira req --user admin -M POST /rest/api/2/project '{"key":"TASK","name":"Task","projectTypeKey":"business","projectTemplateKey":"com.atlassian.jira-core-project-templates:jira-core-task-management","lead":"gojira"}' +``` + +### snapshot docker container +``` +docker commit go-jira-test go-jira-test:latest +``` + +### Destroy base container + +``` +docker rm -f go-jira-test +``` + +## Running Test: + +From the top level of the project you can run: +``` +# this creates a local "jira" binary +make + +# this runs the integration tests in the "t" directory +prove +``` + +## API Documentation: +https://docs.atlassian.com/jira/REST/cloud/ + +## projectTempalteKey missing documentation +https://answers.atlassian.com/questions/36176301/jira-api-7.1.0-create-project +