correct apib config and add dredd test data import/export + working run

pull/32/head
HardiReady 2018-03-24 19:04:22 +01:00
parent c3f5c3f971
commit e284fffdee
27 changed files with 44 additions and 9 deletions

View File

@ -25,7 +25,7 @@ In addition, it sets up the mongo deamon to start up automatically with the syst
For production setup run the script, described in _Setup for development_, adding the parameter `prod`
./docs/opt-cc-environment/3rd-party-install.sh prod
./docs/opt-cc-environment/3rd-party-install.sh prod
This adds the [`pm2` process manager](http://pm2.keymetrics.io/) to be installed and start the _opt-cc_ server as `pm2` process.
Run the `sudo` command printed as last output to configure the `pm2` process for automatic start on the system.

View File

@ -1,7 +1,10 @@
### GET User [GET /users/:id]
### GET User [GET /users/{id}]
Get single army member information
+ Parameters
+ id: `5ab68d42f547ed304064e5f7` (string, required) - unique id of army-member
+ Response 200
+ Attributes (User)

View File

@ -2,7 +2,7 @@
Generate a token which can be used to make API requests.
+ Request Generate Token
+ Request Generate Token (application/json)
+ Attributes (Login)

View File

@ -2,7 +2,7 @@
Create a new application user account.
+ Request Create Account
+ Request Create Account (application/json)
+ Attributes (Registration)

View File

@ -3,7 +3,7 @@ User related entity for creating a token using application credentials
## Properties
+ username: `hardiready` (string, required) - username of the app-user
+ username: `testuser` (string, required) - username of the app-user
+ password: `password` (string, required) - password of the app-user
# LoginResponse (object)

View File

@ -2,7 +2,7 @@
A participant managed in the system
## Properties
+ _id: `5918d2ca574b0b1d820a0b24` (string, required) - unique id of the army member
+ _id: `5ab68d42f547ed304064e5f7` (string, required) - unique id of the army member
+ username: `Jagernaut` - the displayed username of the army member
+ rankLvl: 22 (number, required) - rank level representing the rank
+ squadId (Squad, required) - populated squad which the army member is part of

View File

@ -0,0 +1 @@
{"_id":{"$oid":"5ab68ceef547ed304064e5f6"},"squad":null,"permission":3,"activated":true,"username":"testuser","secret":"my secret","password":"$2a$10$wvgBbcckHrFu8Ctw8hSPNuFLoBy4sRubioyiK1NabOC0UgYD.KITi","timestamp":{"$date":"2018-03-24T17:37:50.668Z"},"updatedAt":{"$date":"2018-03-24T17:37:50.668Z"},"__v":0}

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

@ -0,0 +1 @@
{"_id":{"$oid":"5ab68d42f547ed304064e5f7"},"rankLvl":0,"squadId":null,"username":"user1","timestamp":{"$date":"2018-03-24T17:39:14.841Z"},"updatedAt":{"$date":"2018-03-24T17:39:14.841Z"},"__v":0}

View File

29
api/apib/dredd/populate-data.sh Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
########## IMPORT EXPORT/SCRIPT FOR DREDD TEST DATA ############
###----------------------------------------------------------###
###------------------ HOW TO USE THIS FILE ------------------###
###----------------------------------------------------------###
### 1. start express server with `npm run start-test` ###
### 2. import data by executing script: `./populate-data.sh` ###
### 3. change data in app as you need for tests ###
### 4. export data state with: `./populate-data.sh save` ###
################################################################
# execute script in its location folder
cd $(dirname $0)
# array of available collection names
col=(app_user awarding campaign decoration logBudget logFlag logKill logPoints logRespawn logRevive logTransport player promotion rank squad user war )
for i in "${col[@]}"
do
# provide date for restore process, if data import is needed
if [ "$1" == "save" ]
then
echo -e "$(date "+%Y-%m-%dT%T.%3N%z")\tTable: ${i}"
mongoexport --db cc-test --collection $i --out data/${i}.json;
else
mongoimport --db cc-test --collection $i --drop --file data/${i}.json
fi
done

View File

@ -14,7 +14,7 @@
"start-test": "DEBUG='cc:*' NODE_ENV=test node server.js",
"api:compile-docs": "$(npm bin)/hercule apib/dev-doc.apib -o apib/documentation.apib",
"api:publish-docs": "$(npm bin)/aglio --theme-variables slate -i ./apib/documentation.apib -o ../public/api-docs.html",
"api:test-docs": "$(npm bin)/dredd",
"api:test-docs": "npm run api:docs && ./apib/dredd/populate-data.sh && $(npm bin)/dredd",
"api:docs": "npm run api:compile-docs && npm run api:publish-docs"
},
"dependencies": {

View File

@ -78,7 +78,7 @@ authenticate.route('/signup')
.post((req, res, next) => {
create(req.body)
.then(() => {
res.sendStatus(200);
res.sendStatus(201);
})
.catch((err) => {
res.status(400).send(err);

View File

@ -15,7 +15,8 @@
"test": "npm test --prefix ./api",
"e2e": "npm run deploy-static && concurrently \"npm run start-test --prefix ./api\" \"wait-on -t 60000 http://localhost:3001/ && npm run e2e --prefix ./static\" --success first --kill-others",
"start-e2e": "npm run deploy-static && npm run start-test --prefix ./api",
"test-e2e": "npm run e2e --prefix ./static"
"test-e2e": "npm run e2e --prefix ./static",
"test-api": "npm run api:test-docs --prefix ./api"
},
"dependencies": {},
"devDependencies": {