Skip to content
Snippets Groups Projects
Commit 8fd1965d authored by Colton Leekley-Winslow's avatar Colton Leekley-Winslow
Browse files

Add RAML for ContainerHandler based routes

parent 600d5625
No related branches found
No related tags found
No related merge requests found
Showing
with 440 additions and 84 deletions
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"allOf":[{"ref":"../definitions/group.json#/definitions/group-output"}],
"required": [
"roles",
"created",
"modified",
"_id"
]
}
......@@ -2,6 +2,12 @@
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "array",
"items": {
"$ref":"../definitions/group-output.json#"
"allOf":[{"ref":"../definitions/group.json#/definitions/group-output"}],
"required": [
"roles",
"created",
"modified",
"_id"
]
}
}
......@@ -2,14 +2,23 @@
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "array",
"items": {
"allOf":[
{"$ref":"../definitions/job-output.json#"},
{
"required":[
"_id", "name", "inputs",
"destination", "tags", "state", "attempt"
]
}
"type":"object",
"properties":{
"_id":{"$ref":"../definitions/job.json#/definitions/id"},
"name":{"$ref":"../definitions/job.json#/definitions/name"},
"inputs":{"$ref":"../definitions/job.json#/definitions/inputs-array"},
"destination":{"$ref":"../definitions/job.json#/definitions/destination"},
"tags":{"$ref":"../definitions/job.json#/definitions/tags"},
"state":{"$ref":"../definitions/job.json#/definitions/state"},
"attempt":{"$ref":"../definitions/job.json#/definitions/attempt"},
"created":{"$ref":"../definitions/created-modified.json#/definitions/created"},
"modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"},
"config":{"$ref":"../definitions/job.json#/definitions/config"}
},
"additionalProperties":false,
"required":[
"_id", "name", "inputs",
"destination", "tags", "state", "attempt"
]
}
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type":"object",
"properties":{
"_id":{"$ref":"../definitions/job.json#/definitions/id"},
"name":{"$ref":"../definitions/job.json#/definitions/name"},
"inputs":{"$ref":"../definitions/job.json#/definitions/inputs-array"},
"destination":{"$ref":"../definitions/job.json#/definitions/destination"},
"tags":{"$ref":"../definitions/job.json#/definitions/tags"},
"state":{"$ref":"../definitions/job.json#/definitions/state"},
"attempt":{"$ref":"../definitions/job.json#/definitions/attempt"},
"created":{"$ref":"../definitions/created-modified.json#/definitions/created"},
"modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"},
"config":{"$ref":"../definitions/job.json#/definitions/config"},
"request":{"$ref":"../definitions/job.json#/definitions/request"}
},
"additionalProperties":false,
"required":[
"_id", "name", "inputs", "config",
"destination", "tags", "state", "attempt"
]
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"allOf":[
{"$ref":"../definitions/job.json#"},
{"$ref":"../definitions/created-modified.json#"},
{
"type":"object",
"properties":{
"id":{"type":"string"},
"name":{},
"inputs":{},
"destination":{},
"origin": {},
"saved_files": {},
"tags":{},
"state":{},
"attempt":{},
"created":{},
"modified":{},
"config":{
"oneOf":[
{
"enum":[null]
},
{
"type":"object"
}
]
}
},
"additionalProperties":false
}
],
"type":"object",
"properties":{
"id":{"$ref":"../definitions/job.json#/definitions/id"},
"name":{"$ref":"../definitions/job.json#/definitions/name"},
"inputs":{"$ref":"../definitions/job.json#/definitions/inputs-object"},
"destination":{"$ref":"../definitions/job.json#/definitions/destination"},
"tags":{"$ref":"../definitions/job.json#/definitions/tags"},
"state":{"$ref":"../definitions/job.json#/definitions/state"},
"attempt":{"$ref":"../definitions/job.json#/definitions/attempt"},
"created":{"$ref":"../definitions/created-modified.json#/definitions/created"},
"modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"},
"config":{"$ref":"../definitions/job.json#/definitions/config"},
"request":{"$ref":"../definitions/job.json#/definitions/request"},
"saved_files":{"$ref":"../definitions/job.json#/definitions/saved_files"}
},
"additionalProperties":false,
"required":[
"id", "name", "inputs", "config",
"destination", "tags", "state", "attempt",
......
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type":"array",
"items":{
"type": "object",
"allOf": [{"$ref": "../definitions/project.json#/definitions/project-output"}],
"required": [
"_id", "label", "group",
"created", "modified", "permissions"
]
}
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Project",
"type": "object",
"allOf": [{"$ref": "../definitions/project.json#/definitions/project-output"}],
"required": [
"_id", "label", "group",
"created", "modified", "permissions"
]
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"patternProperties": {
"^[a-fA-F0-9]{24}$":{
"type":"array",
"items":{
"type":"object",
"properties":{
"id":{"$ref":"../definitions/job.json#/definitions/id"},
"name":{"$ref":"../definitions/job.json#/definitions/name"},
"inputs":{"$ref":"../definitions/job.json#/definitions/inputs-object"},
"destination":{"$ref":"../definitions/job.json#/definitions/destination"},
"tags":{"$ref":"../definitions/job.json#/definitions/tags"},
"state":{"$ref":"../definitions/job.json#/definitions/state"},
"attempt":{"$ref":"../definitions/job.json#/definitions/attempt"},
"created":{"$ref":"../definitions/created-modified.json#/definitions/created"},
"modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"},
"config":{"$ref":"../definitions/job.json#/definitions/config"},
"request":{"$ref":"../definitions/job.json#/definitions/request"}
},
"additionalProperties":false,
"required":[
"id", "name", "inputs", "config",
"destination", "tags", "state", "attempt"
]
}
}
},
"additionalProperties":false
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type":"array",
"items":{
"allOf":[{"$ref":"../definitions/session.json#/definitions/session-output"}],
"required":[
"_id", "label", "project", "created", "modified", "permissions",
"public", "group", "subject"
]
}
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type":"object",
"allOf":[{"$ref":"../definitions/session.json#/definitions/session-output"}],
"required":[
"_id", "label", "project", "created", "modified", "permissions",
"public", "group", "subject"
]
}
......@@ -3,13 +3,11 @@
"type": "array",
"items": {
"allOf":[
{"$ref":"../definitions/user-output.json#"},
{
"required":[
"_id", "firstname", "lastname",
"root", "email", "created", "modified"
]
}
{"$ref":"../definitions/user.json#/definitions/user-output"}
],
"required":[
"_id", "firstname", "lastname",
"root", "email", "created", "modified"
]
}
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"allOf":[
{"$ref":"../definitions/user.json#"},
{"$ref":"../definitions/created-modified.json"},
{
"type":"object",
"properties":{
"_id":{},
"firstname":{},
"lastname":{},
"email":{},
"avatars":{},
"root":{},
"disabled":{},
"preferences":{},
"created":{},
"modified":{},
"api_key": {"$ref":"../definitions/user-api_key.json"}
},
"additionalProperties":false,
"required":[
"_id", "firstname", "lastname",
"root", "email", "created", "modified"
]
}
"type":"object",
"properties":{
"_id":{"$ref":"../definitions/user.json#/definitions/_id"},
"firstname":{"$ref":"../definitions/user.json#/definitions/firstname"},
"lastname":{"$ref":"../definitions/user.json#/definitions/lastname"},
"email":{"$ref":"../definitions/user.json#/definitions/email"},
"avatar":{"$ref":"../definitions/user.json#/definitions/avatar"},
"avatars":{"$ref":"../definitions/user.json#/definitions/avatars"},
"root":{"$ref":"../definitions/user.json#/definitions/root"},
"disabled":{"$ref":"../definitions/user.json#/definitions/disabled"},
"preferences":{"$ref":"../definitions/user.json#/definitions/preferences"},
"created":{"$ref":"../definitions/created-modified.json#/definitions/created"},
"modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"},
"api_key":{"$ref":"../definitions/user.json#/definitions/api_key"}
},
"additionalProperties":false,
"required":[
"_id", "firstname", "lastname",
"root", "email", "created", "modified"
]
}
......@@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"allOf":[
{"$ref":"../definitions/user-output.json#"},
{"$ref":"../definitions/user.json#/definitions/user-output"},
{
"required":[
"_id", "firstname", "lastname",
......
......@@ -52,10 +52,17 @@ BASE_URL="$SCITRAN_SITE_API_URL" \
MONGO_PATH="$MONGODB_URI" \
py.test test/integration_tests/python
PATH=$(npm bin):$PATH
# Allow us to require modules from package.json,
# since abao_test_hooks.js is not being called from the package directory
integration_test_node_modules="$( pwd )/node_modules/scitran-core-integration-tests/node_modules"
newman run test/integration_tests/postman/integration_tests.postman_collection -e test/integration_tests/postman/environments/integration_tests.postman_environment
# Have to change into definitions directory to resolve
# relative $ref's in the jsonschema's
pushd raml/schemas/definitions
abao ../../api.raml "--server=$SCITRAN_SITE_API_URL" "--hookfiles=../../../test/integration_tests/abao/abao_test_hooks.js"
# NODE_PATH="$integration_test_node_modules"
NODE_PATH="$integration_test_node_modules" abao ../../api.raml "--server=$SCITRAN_SITE_API_URL" "--hookfiles=../../../test/integration_tests/abao/abao_test_hooks.js"
popd
......@@ -9,8 +9,8 @@ NODE_URL="https://nodejs.org/dist/v6.4.0/node-v6.4.0-linux-x64.tar.gz"
if [ -z "$VIRTUAL_ENV" ]; then
curl $NODE_URL | sudo tar xz -C /usr/local --strip-components 1
sudo npm install -g test/integration_tests
npm install test/integration_tests
else
curl $NODE_URL | tar xz -C $VIRTUAL_ENV --strip-components 1
npm install -g test/integration_tests
npm install test/integration_tests
fi
var hooks = require('hooks');
var chai = require("chai");
var assert = chai.assert;
// Variables for passing results as input to subsequent tests
var job_id = '';
var gear_name = 'test-case-gear';
var group_id = 'test_group';
var collection_id = '';
var delete_collection_id = '';
var test_session_1 = null;
var test_session_2_id = null;
var test_acquisition_1 = null;
var test_project_1 = null;
// Tests we're skipping, fix these
// Fails only in travis
hooks.skip("GET /version -> 200");
// Skipped due to 500 when should 4xx
// Should 400 to say invalid json
hooks.skip("GET /download -> 400");
......@@ -23,10 +29,6 @@ hooks.skip("POST /upload/uid-match -> 402");
// Should 404
hooks.skip("GET /jobs/{JobId} -> 404");
// This does run after a job is added
// 500 saying unknown gear
hooks.skip("GET /jobs/next -> 200");
// Can only retry a failed job
hooks.skip("POST /jobs/{JobId}/retry -> 200");
......@@ -34,7 +36,9 @@ hooks.skip("POST /jobs/{JobId}/retry -> 200");
hooks.skip("GET /users/self/avatar -> 307");
hooks.skip("GET /users/{UserId}/avatar -> 307");
// Skipping some tests until we figure out how to test file fields
// Tests that are skipped because we do them in postman or python
// Skipping because abao doesn't support file fields
hooks.skip("POST /download -> 200");
hooks.skip("GET /download -> 200");
hooks.skip("POST /upload/label -> 200");
......@@ -193,3 +197,161 @@ hooks.before("DELETE /groups/{GroupId} -> 200", function(test, done) {
};
done();
});
hooks.after("GET /collections -> 200", function(test, done) {
collection_id = test.response.body[0]._id;
delete_collection_id = test.response.body[1]._id;
done();
});
hooks.before("GET /collections/{CollectionId} -> 200", function(test, done) {
test.request.params.CollectionId = collection_id;
done();
});
hooks.before("GET /collections/{CollectionId}/sessions -> 200", function(test, done) {
test.request.params.CollectionId = collection_id;
done();
});
hooks.before("GET /collections/{CollectionId}/acquisitions -> 200", function(test, done) {
test.request.params.CollectionId = collection_id;
done();
});
hooks.before("POST /collections -> 400", function(test, done) {
test.request.params.CollectionId = collection_id;
test.request.body.foo = "not an allowed property";
done();
});
hooks.before("PUT /collections/{CollectionId} -> 400", function(test, done) {
test.request.params.CollectionId = collection_id;
test.request.body.foo = "not an allowed property";
done();
});
hooks.before("DELETE /collections/{CollectionId} -> 200", function(test, done) {
test.request.params.CollectionId = delete_collection_id;
done();
});
hooks.after("GET /sessions -> 200", function(test, done) {
test_session_1 = test.response.body[0];
assert.equal(test_session_1.label, "test-session-1");
done();
});
hooks.before("GET /sessions/{SessionId} -> 200", function(test, done) {
test.request.params.SessionId = test_session_1._id;
done();
});
hooks.before("POST /sessions -> 200", function(test, done) {
test.request.body.project = test_session_1.project;
done();
});
hooks.after("POST /sessions -> 200", function(test, done) {
test_session_2_id = test.response.body._id
done();
});
hooks.before("POST /sessions -> 400", function(test, done) {
test.request.body.foo = "not an allowed property";
test.request.body.project = test_session_1.project;
done();
});
hooks.before("PUT /sessions/{SessionId} -> 200", function(test, done) {
test.request.params.SessionId = test_session_1._id;
test.request.body = {
project: test_session_1.project,
label: "new-label-test-session-1"
};
done();
});
hooks.before("PUT /sessions/{SessionId} -> 400", function(test, done) {
test.request.params.SessionId = test_session_1._id;
test.request.body = {
project: test_session_1.project,
"not_a_real_property": "new-label-test-session-1"
};
done();
});
hooks.before("DELETE /sessions/{SessionId} -> 200", function(test, done) {
test.request.params.SessionId = test_session_2_id;
done();
});
hooks.before("GET /sessions/{SessionId}/jobs -> 200", function(test, done) {
test.request.params.SessionId = test_session_1._id;
done();
});
hooks.after("GET /acquisitions -> 200", function(test, done) {
test_acquisition_1 = test.response.body[0];
assert.equal(test_acquisition_1.label, "test-acquisition-1");
example_acquisition = test.response.body[1];
done();
});
hooks.before("GET /acquisitions/{AcquisitionId} -> 200", function(test, done) {
test.request.params.AcquisitionId = test_acquisition_1._id;
done();
});
hooks.before("POST /acquisitions -> 200", function(test, done) {
test.request.body.session = test_session_1._id;
done();
});
hooks.before("POST /acquisitions -> 400", function(test, done) {
test.request.body.session = test_session_1._id;
test.request.body.foo = "bar";
done();
});
hooks.before("PUT /acquisitions/{AcquisitionId} -> 200", function(test, done) {
test.request.params.AcquisitionId = test_acquisition_1._id;
test.request.body = {"label":"test-acquisition-1-new-label"};
done();
});
hooks.before("PUT /acquisitions/{AcquisitionId} -> 400", function(test, done) {
test.request.params.AcquisitionId = test_acquisition_1._id;
test.request.body = {"not-real":"an invalid property"};
done();
});
hooks.before("DELETE /acquisitions/{AcquisitionId} -> 200", function(test, done) {
test.request.params.AcquisitionId = example_acquisition._id;
done();
});
hooks.after("GET /projects -> 200", function(test, done) {
test_project_1 = test.response.body[0];
assert.equal(test_project_1.label, "test-project");
done();
});
hooks.before("POST /projects -> 400", function(test, done) {
test.request.body.not_real = "an invalid property";
done();
});
hooks.before("GET /projects/{ProjectId} -> 200", function(test, done) {
test.request.params.ProjectId = test_project_1._id;
done();
});
hooks.before("PUT /projects/{ProjectId} -> 400", function(test, done) {
test.request.params.ProjectId = test_project_1._id;
test.request.body = {"not_real":"fake property"};
done();
});
......@@ -4,7 +4,8 @@
"description": "SciTran Core integation test node dependencies",
"dependencies": {
"newman":"3.1.0",
"abao":"git+https://github.com/flywheel-io/abao.git#better-jsonschema-ref"
"abao":"git+https://github.com/flywheel-io/abao.git#better-jsonschema-ref",
"chai": "~3.5.0"
},
"bin":{
"abao":"node_modules/.bin/abao",
......
......@@ -356,6 +356,93 @@
},
"response": []
},
{
"name": "Create test-collection-1",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": "tests[\"Status code is 200\"] = responseCode.code === 200;\n\ntests[\"Response time is less than 200ms\"] = responseTime < 200;\n\nvar jsonData = JSON.parse(responseBody);\n\npostman.setGlobalVariable(\"test-collection-id\", jsonData._id);"
}
}
],
"request": {
"url": "{{baseUri}}/collections",
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "scitran-user {{test_user_api_key}}",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n \"label\":\"test-collection-1\"\n}"
},
"description": ""
},
"response": []
},
{
"name": "Add test-session-1 to test-collection-1",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": "tests[\"Status code is 200\"] = responseCode.code === 200;\n\ntests[\"Response time is less than 200ms\"] = responseTime < 200;"
}
}
],
"request": {
"url": "{{baseUri}}/collections/{{test-collection-id}}",
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "scitran-user {{test_user_api_key}}",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n \"contents\":{\n \t\"operation\":\"add\",\n \t\"nodes\":[\n \t\t{\n \t\t\t\"level\":\"session\",\n \t\t\t\"_id\":\"{{test-session-id}}\"\n \t\t}\n \t]\n }\n}"
},
"description": ""
},
"response": []
},
{
"name": "Create test-collection-2",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": "tests[\"Status code is 200\"] = responseCode.code === 200;\n\ntests[\"Response time is less than 200ms\"] = responseTime < 200;"
}
}
],
"request": {
"url": "{{baseUri}}/collections",
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "scitran-user {{test_user_api_key}}",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n \"label\":\"test-collection-2\"\n}"
},
"description": ""
},
"response": []
},
{
"name": "[Session Template] Create project",
"event": [
......@@ -734,4 +821,4 @@
"response": []
}
]
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment