diff --git a/bin/lrs-test.js b/bin/lrs-test.js index ed1a0ab..43a108f 100755 --- a/bin/lrs-test.js +++ b/bin/lrs-test.js @@ -6,10 +6,12 @@ (function (process, require, program, exit, packageJson, Q, Joi, fs, path, Mocha) { 'use strict'; + var DIRECTORY = 'v1_0_2'; + program .version(packageJson.version) .usage('[options]') - .option('-d, --directory [path]', 'test directory, default: test/v1_0_2') + .option('-d, --directory [path]', 'test directory, default: ' + DIRECTORY) .option('-e, --endpoint ', 'the connection string') .option('-a, --basicAuth ', 'enables basic authentication') .option('-u, --authUser ', 'sets user name (required when basic authentication enabled)') @@ -33,7 +35,7 @@ process.nextTick(function () { var options = { - directory: program.directory || 'test/v1_0_2', + directory: program.directory || DIRECTORY, endpoint: program.endpoint, basicAuth: program.basicAuth, authUser: program.authUser, @@ -48,7 +50,7 @@ process.env.BASIC_AUTH_ENABLED = options.basicAuth; process.env.BASIC_AUTH_USER = options.authUser; process.env.BASIC_AUTH_PASSWORD = options.authPass; - var testDirectory = options.directory; + var testDirectory = 'test/' + options.directory; fs.readdirSync(testDirectory).filter(function (file) { return file.substr(-3) === '.js'; }).forEach(function (file) { diff --git a/package.json b/package.json index 9a689eb..96ab404 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lrs-conformance-tests", - "version": "0.0.3", + "version": "1.1.1", "description": "lrs-conformance-tests", "main": "test.js", "scripts": { @@ -42,6 +42,6 @@ "super-request": "0.0.8", "supertest": "^0.13.0", "supertest-as-promised": "^1.0.0", - "valid-url": "^1.0.9" + "validator": "^3.39.0" } } diff --git a/test/.env b/test/.env index 6101a26..6940662 100644 --- a/test/.env +++ b/test/.env @@ -1,5 +1,6 @@ LRS_ENDPOINT=http://asdf.elmnts-test.com:8001/lrs XAPI_VERSION=1.0.1 +DIRECTORY=v1_0_2 BASIC_AUTH_ENABLED=false BASIC_AUTH_USER=username BASIC_AUTH_PASSWORD=password \ No newline at end of file diff --git a/test/helper.js b/test/helper.js index 43ccb24..753fc1f 100644 --- a/test/helper.js +++ b/test/helper.js @@ -17,6 +17,9 @@ if (!process.env.EB_NODE_COMMAND) { /** Appears to use relative path */ var CONFIG_FOLDER_RELATIVE = './v1_0_2/configs'; + /** Test directory */ + var DIRECTORY = process.env.DIRECTORY; + /** Defines endpoint of the LRS you are testing. Currently assumes authentication is not required */ var LRS_ENDPOINT = process.env.LRS_ENDPOINT; @@ -315,7 +318,9 @@ if (!process.env.EB_NODE_COMMAND) { * @returns {string} */ buildActivity: function () { - return 'http://www.example.com/activityId/hashset'; + return { + activityId: 'http://www.example.com/activityId/hashset' + }; }, /** * Returns an example State params. @@ -350,7 +355,6 @@ if (!process.env.EB_NODE_COMMAND) { */ buildAgentProfile: function () { return { - activityId: 'http://www.example.com/activityId/hashset', agent: { "objectType": "Agent", "account": { @@ -396,7 +400,7 @@ if (!process.env.EB_NODE_COMMAND) { * @returns {object} statement */ buildStatement: function () { - return clone(require('../data/statement_full.json')); + return module.exports.clone(require('./' + DIRECTORY + '/templates/statements/default.json')); }, /** * Deep clone object. diff --git a/test/v1_0_2/document.js b/test/v1_0_2/document.js index 4140c46..101d78d 100644 --- a/test/v1_0_2/document.js +++ b/test/v1_0_2/document.js @@ -5,9 +5,13 @@ * https://github.com/adlnet/xAPI_LRS_Test/blob/master/TestingRequirements.md * */ -(function (process, request, should, helper, qs, validUrl) { +(function (process, request, should, chai, qs, validator, helper) { 'use strict'; + var expect = chai.expect; + + var MAIL_TO = 'mailto:'; + var request = request(helper.getEndpoint()); /** @@ -36,34 +40,29 @@ it('An LRS has a State API with endpoint "base IRI"+"/activities/state" (7.3.table1.row1.a ,7.3.table1.row1.c)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); - return sendRequest('post', '/activities/state', parameters, document, 204); + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204); }); it('An LRS has an Activities API with endpoint "base IRI" + /activities" (7.5) **Implicit** (in that it is not named this by the spec)', function () { - var parameters = { - activityId: 'http://www.example.com/activityId/hashset' - }; - return sendRequest('post', '/activities/state', parameters, document, 204); + var parameters = helper.buildActivity(); + return sendRequest('get', helper.getEndpointActivities(), parameters, undefined, 200); }); it('An LRS has an Activity Profile API with endpoint "base IRI"+"/activities/profile" (7.3.table1.row2.a, 7.3.table1.row2.c)', function () { var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); - return sendRequest('post', '/activities/profile', parameters, document, 204); + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 204); }); - it('An LRS has an Agents API with endpoint "base IRI" + /agents" (7.6) **Implicit** (in that it is not named this by the spec)', function (done) { - // TODO Talk to Freddie about Agents - var parameters = { - objectType: 'Person' - }; - return sendRequest('get', '/agents', parameters, undefined, 200); + it('An LRS has an Agents API with endpoint "base IRI" + /agents" (7.6) **Implicit** (in that it is not named this by the spec)', function () { + var parameters = helper.buildAgentProfile(); + return sendRequest('get', helper.getEndpointAgents(), parameters, undefined, 200); }); it('An LRS has an Agent Profile API with endpoint "base IRI"+"/agents/profile" (7.3.table1.row3.a, 7.3.table1.row3.c)', function () { var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); - return sendRequest('post', '/agents/profile', parameters, document, 204); + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 204); }); it('An LRS has an About API with endpoint "base IRI"+"/about" (7.7.a)', function () { @@ -73,47 +72,47 @@ it('An LRS will accept a POST request to the State API (7.3.table1.row1.b)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); - return sendRequest('post', '/activities/state', parameters, document, 204); + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204); }); it('An LRS will accept a POST request to the Activity Profile API (7.3.table1.row2.b)', function () { var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); - return sendRequest('post', '/activities/profile', parameters, document, 204); + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 204); }); it('An LRS will accept a POST request to the Agent Profile API (7.3.table1.row3.b)', function () { var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); - return sendRequest('post', '/agents/profile', parameters, document, 204); + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 204); }); - describe('An LRS cannot reject a POST request to the State API based on the contents of the name/value pairs of the document (7.3.b) **Implicit**', function (done) { - var parameters = helper.buildState(), - documents = [helper.buildDocument(), 1, true, undefined]; + describe('An LRS cannot reject a POST request to the State API based on the contents of the name/value pairs of the document (7.3.b) **Implicit**', function () { + var documents = [helper.buildDocument(), '1', 'true', undefined]; documents.forEach(function (document) { it('Should accept POST to State with document ' + document, function () { - return sendRequest('post', '/activities/state', parameters, document, 204); + var parameters = helper.buildState(); + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204); }); }); }); describe('An LRS cannot reject a POST request to the Activity Profile API based on the contents of the name/value pairs of the document (7.3.b) **Implicit**', function () { - var parameters = helper.buildActivityProfile(), - documents = [helper.buildDocument(), 1, true, undefined]; + var documents = [helper.buildDocument(), '1', 'true', undefined]; documents.forEach(function (document) { it('Should accept POST to Activity profile with document ' + document, function () { - return sendRequest('post', '/activities/profile', parameters, document, 204); + var parameters = helper.buildActivityProfile(); + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 204); }); }); }); describe('An LRS cannot reject a POST request to the Agent Profile API based on the contents of the name/value pairs of the document (7.3.b) **Implicit**', function () { - var parameters = helper.buildAgentProfile(), - documents = [{}, 1, true, undefined]; + var documents = [{}, '1', 'true', undefined]; documents.forEach(function (document) { it('Should accept POST to Agent profile with document ' + document, function () { - return sendRequest('post', '/agents/profile', parameters, document, 204); + var parameters = helper.buildAgentProfile(); + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 204); }); }); }); @@ -121,11 +120,12 @@ it('An LRS\'s State API, upon receiving a POST request for a document not currently in the LRS, treats it as a PUT request and store a new document (7.3.f)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); - return sendRequest('post', '/activities/state', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204) .then(function () { - return sendRequest('get', '/activities/state', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 200) .then(function (res) { - res.body.should.eql(document); + var body = res.body; + expect(body).to.eql(document); }); }); }); @@ -134,9 +134,9 @@ var parameters = helper.buildState(), document = helper.buildDocument(), anotherDocument = 'abc'; - return sendRequest('post', '/activities/state', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204) .then(function () { - return sendRequest('post', '/activities/state', parameters, anotherDocument, 400); + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, anotherDocument, 400); }); }); @@ -163,13 +163,14 @@ anotherDocument = { type: 'Civic' }; - return sendRequest('post', '/activities/state', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204) .then(function () { - return sendRequest('post', '/activities/state', parameters, anotherDocument, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, anotherDocument, 204) .then(function () { - return sendRequest('get', '/activities/state', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 200) .then(function (res) { - res.body.should.eql({ + var body = res.body; + expect(body).to.eql({ car: 'Honda', type: 'Civic' }) @@ -181,11 +182,12 @@ it('An LRS\'s Activity Profile API, upon receiving a POST request for a document not currently in the LRS, treats it as a PUT request and store a new document (7.3.f)', function () { var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); - return sendRequest('post', '/activities/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 204) .then(function () { - return sendRequest('get', '/activities/profile', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointActivitiesProfile(), parameters, undefined, 200) .then(function (res) { - res.body.should.eql(document); + var body = res.body; + expect(body).to.eql(document); }) }); }); @@ -194,9 +196,9 @@ var parameters = helper.buildActivityProfile(), document = helper.buildDocument(), anotherDocument = 'abc'; - return sendRequest('post', '/activities/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 204) .then(function () { - return sendRequest('post', '/activities/profile', parameters, anotherDocument, 400); + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, anotherDocument, 400); }); }); @@ -208,13 +210,14 @@ anotherDocument = { type: 'Civic' }; - return sendRequest('post', '/activities/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 204) .then(function () { - return sendRequest('post', '/activities/profile', parameters, anotherDocument, 204) + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, anotherDocument, 204) .then(function () { - return sendRequest('get', '/activities/profile', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointActivitiesProfile(), parameters, undefined, 200) .then(function (res) { - res.body.should.eql({ + var body = res.body; + expect(body).to.eql({ car: 'Honda', type: 'Civic' }) @@ -226,11 +229,12 @@ it('An LRS\'s Agent Profile API, upon receiving a POST request for a document not currently in the LRS, treats it as a PUT request and store a new document (7.3.f)', function () { var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); - return sendRequest('post', '/agents/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 204) .then(function () { - return sendRequest('get', '/agents/profile', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointAgentsProfile(), parameters, undefined, 200) .then(function (res) { - res.body.should.eql(document); + var body = res.body; + expect(body).to.eql(document); }) }); }); @@ -239,9 +243,9 @@ var parameters = helper.buildAgentProfile(), document = helper.buildDocument(), anotherDocument = 'abc'; - return sendRequest('post', '/agents/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 204) .then(function () { - return sendRequest('post', '/agents/profile', parameters, anotherDocument, 400); + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, anotherDocument, 400); }); }); @@ -253,13 +257,14 @@ anotherDocument = { type: 'Civic' }; - return sendRequest('post', '/agents/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 204) .then(function () { - return sendRequest('post', '/agents/profile', parameters, anotherDocument, 204) + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, anotherDocument, 204) .then(function () { - return sendRequest('get', '/agents/profile', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointAgentsProfile(), parameters, undefined, 200) .then(function (res) { - res.body.should.eql({ + var body = res.body; + expect(body).to.eql({ car: 'Honda', type: 'Civic' }) @@ -271,24 +276,24 @@ it('An LRS\'s State API accepts PUT requests (7.4)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); - return sendRequest('put', '/activities/state', parameters, document, 204); + return sendRequest('put', helper.getEndpointActivitiesState(), parameters, document, 204); }); it('An LRS\'s State API rejects a PUT request without "activityId" as a parameter with error code 400 Bad Request (multiplicity, 7.4.table1.row1.b)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); delete parameters.activityId; - return sendRequest('put', '/activities/state', parameters, document, 400); + return sendRequest('put', helper.getEndpointActivitiesState(), parameters, document, 400); }); - describe('An LRS\'s State API rejects a PUT request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.4.table1.row1.a)', function () { - var invalidTypes = [{}, 1, true, undefined]; + describe('An LRS\'s State API rejects a PUT request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.4.table1.row1.a)', function () { + var invalidTypes = [{ key: 'value'}, 1, true, undefined]; invalidTypes.forEach(function (type) { it('Should State API reject a PUT request with activityId type ' + type, function () { var parameters = helper.buildState(), document = helper.buildDocument(); delete parameters.activityId; - return sendRequest('put', '/activities/state', parameters, document, 400); + return sendRequest('put', helper.getEndpointActivitiesState(), parameters, document, 400); }); }); }); @@ -298,31 +303,31 @@ var parameters = helper.buildState(), document = helper.buildDocument(); delete parameters.agent; - return sendRequest('put', '/activities/state', parameters, document, 400); + return sendRequest('put', helper.getEndpointActivitiesState(), parameters, document, 400); }); it('An LRS\'s State API rejects a PUT request with "agent" as a parameter if it is not in JSON format with error code 400 Bad Request (format, 7.4.table1.row2.a)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); parameters.agent = 'not JSON brah'; - return sendRequest('put', '/activities/state', parameters, document, 400); + return sendRequest('put', helper.getEndpointActivitiesState(), parameters, document, 400); }); - it('An LRS\'s State API can process a PUT request with "registration" as a parameter (multiplicity, 7.4.table1.row3.b)', function () { + it('An LRS\'s State API can process a PUT request with "registration" as a parameter (multiplicity, 7.4.table1.row3.b)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); parameters.registration = helper.generateUUID(); - return sendRequest('put', '/activities/state', parameters, document, 204); + return sendRequest('put', helper.getEndpointActivitiesState(), parameters, document, 204); }); describe('An LRS\'s State API rejects a PUT request with "registration" as a parameter if it is not a UUID with error code 400 Bad Request(format, 7.4.table1.row3.a)', function () { - var parameters = helper.buildState(), - document = helper.buildDocument(), + var document = helper.buildDocument(), invalidTypes = [1, true, 'not UUID']; invalidTypes.forEach(function (type) { it('Should reject PUT with "registration" with type ' + type, function () { + var parameters = helper.buildState(); parameters.registration = type; - return sendRequest('put', '/activities/state', parameters, document, 400); + return sendRequest('put', helper.getEndpointActivitiesState(), parameters, document, 400); }); }); }); @@ -331,17 +336,17 @@ var parameters = helper.buildState(), document = helper.buildDocument(); delete parameters.stateId; - return sendRequest('put', '/activities/state', parameters, document, 400); + return sendRequest('put', helper.getEndpointActivitiesState(), parameters, document, 400); }); - describe('An LRS\'s State API rejects a PUT request with "stateId" as a parameter if it is not type "String" with error code 400 Bad Request(format, 7.4.table1.row1.a)', function () { - var parameters = helper.buildState(), - document = helper.buildDocument(), - invalidTypes = [1, true, {}, undefined]; + describe('An LRS\'s State API rejects a PUT request with "stateId" as a parameter if it is not type "String" with error code 400 Bad Request(format, 7.4.table1.row1.a)', function () { + var document = helper.buildDocument(), + invalidTypes = [{ key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject PUT State with stateId type : ' + type, function () { + var parameters = helper.buildState(); parameters.stateId = type; - return sendRequest('put', '/activities/state', parameters, document, 400); + return sendRequest('put', helper.getEndpointActivitiesState(), parameters, document, 400); }); }); }); @@ -349,30 +354,30 @@ it('An LRS\'s State API upon processing a successful PUT request returns code 204 No Content (7.4.a)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); - return sendRequest('put', '/activities/state', parameters, document, 204); + return sendRequest('put', helper.getEndpointActivitiesState(), parameters, document, 204); }); it('An LRS\'s State API accepts POST requests (7.4)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); - return sendRequest('post', '/activities/state', parameters, document, 204); + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204); }); it('An LRS\'s State API rejects a POST request without "activityId" as a parameter with error code 400 Bad Request (multiplicity, 7.4.table1.row1.b)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); delete parameters.activityId; - return sendRequest('post', '/activities/state', parameters, document, 400); + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 400); }); - describe('An LRS\'s State API rejects a POST request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.4.table1.row1.a)', function () { - var parameters = helper.buildState(), - document = helper.buildDocument(), - invalidTypes = [1, true, {}, undefined]; + describe('An LRS\'s State API rejects a POST request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.4.table1.row1.a)', function () { + var document = helper.buildDocument(), + invalidTypes = [1, true, { key: 'value'}, undefined]; invalidTypes.forEach(function (type) { it('Should reject PUT State with stateId type : ' + type, function () { + var parameters = helper.buildState(); parameters.activityId = type; - return sendRequest('post', '/activities/state', parameters, document, 400); + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 400); }); }); }); @@ -381,17 +386,17 @@ var parameters = helper.buildState(), document = helper.buildDocument(); delete parameters.agent; - return sendRequest('post', '/activities/state', parameters, document, 400); + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 400); }); describe('An LRS\'s State API rejects a POST request with "agent" as a parameter if it is not in JSON format with error code 400 Bad Request (format, 7.4.table1.row2.a)', function () { - var parameters = helper.buildState(), - document = helper.buildDocument(), + var document = helper.buildDocument(), invalidTypes = [1, true, 'not JSON', undefined]; invalidTypes.forEach(function (type) { it('Should reject POST State with agent type : ' + type, function () { + var parameters = helper.buildState(); parameters.agent = type; - return sendRequest('post', '/activities/state', parameters, document, 400); + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 400); }); }); }); @@ -400,17 +405,17 @@ var parameters = helper.buildState(), document = helper.buildDocument(); parameters.registration = helper.generateUUID(); - return sendRequest('post', '/activities/state', parameters, document, 204); + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204); }); describe('An LRS\'s State API rejects a POST request with "registration" as a parameter if it is not a UUID with error code 400 Bad Request (format, 7.4.table1.row3.a)', function () { - var parameters = helper.buildState(), - document = helper.buildDocument(), + var document = helper.buildDocument(), invalidTypes = [1, true, 'not UUID']; invalidTypes.forEach(function (type) { it('Should reject PUT with "registration" with type ' + type, function () { + var parameters = helper.buildState(); parameters.registration = type; - return sendRequest('post', '/activities/state', parameters, document, 400); + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 400); }); }); }); @@ -419,17 +424,17 @@ var parameters = helper.buildState(), document = helper.buildDocument(); delete parameters.stateId; - return sendRequest('post', '/activities/state', parameters, document, 400); + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 400); }); - describe('An LRS\'s State API rejects a POST request with "stateId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.4.table1.row1.a)', function () { - var parameters = helper.buildState(), - document = helper.buildDocument(), - invalidTypes = [1, true, {}, undefined]; + describe('An LRS\'s State API rejects a POST request with "stateId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.4.table1.row1.a)', function () { + var document = helper.buildDocument(), + invalidTypes = [{ key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject POST with "stateId" with type ' + type, function () { + var parameters = helper.buildState(); parameters.stateId = type; - return sendRequest('post', '/activities/state', parameters, document, 400); + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 400); }); }); }); @@ -437,17 +442,18 @@ it('An LRS\'s State API upon processing a successful POST request returns code 204 No Content (7.4.a)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); - return sendRequest('post', '/activities/state', parameters, document, 204); + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204); }); it('An LRS\'s State API accepts GET requests (7.4)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); - return sendRequest('post', '/activities/state', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204) .then(function () { - return sendRequest('get', '/activities/state', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 200) .then(function (res) { - res.body.should.eql(document); + var body = res.body; + expect(body).to.eql(document); }); }); }); @@ -455,16 +461,16 @@ it('An LRS\'s State API rejects a GET request without "activityId" as a parameter with error code 400 Bad Request (multiplicity, 7.4.table1.row1.b)', function () { var parameters = helper.buildState(); delete parameters.activityId; - return sendRequest('get', '/activities/state', parameters, undefined, 400); + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 400); }); - describe('An LRS\'s State API rejects a GET request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.4.table1.row1.a)', function () { - var parameters = helper.buildState(), - invalidTypes = [1, true, {}, undefined]; + describe('An LRS\'s State API rejects a GET request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.4.table1.row1.a)', function () { + var invalidTypes = [1, true, { key: 'value'}, undefined]; invalidTypes.forEach(function (type) { it('Should reject GET with "activityId" with type ' + type, function () { + var parameters = helper.buildState(); parameters.activityId = type; - return sendRequest('get', '/activities/state', parameters, undefined, 400); + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 400); }); }); }); @@ -472,16 +478,16 @@ it('An LRS\'s State API rejects a GET request without "agent" as a parameter with error code 400 Bad Request (multiplicity, 7.4.table1.row2.b)', function () { var parameters = helper.buildState(); delete parameters.agent; - return sendRequest('get', '/activities/state', parameters, undefined, 400); + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 400); }); describe('An LRS\'s State API rejects a GET request with "agent" as a parameter if it is not in JSON format with error code 400 Bad Request (format, 7.4.table1.row2.a)', function () { - var parameters = helper.buildState(), - invalidTypes = [1, true, 'not JSON bruh', undefined]; + var invalidTypes = [1, true, 'not JSON bruh', undefined]; invalidTypes.forEach(function (type) { it('Should reject GET with "agent" with type ' + type, function () { + var parameters = helper.buildState(); parameters.agent = type; - return sendRequest('get', '/activities/state', parameters, undefined, 400); + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 400); }); }); }); @@ -490,22 +496,23 @@ var parameters = helper.buildState(), document = helper.buildDocument(); parameters.registration = helper.generateUUID(); - return sendRequest('post', '/activities/state', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204) .then(function () { - return sendRequest('get', '/activities/state', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 200) .then(function (res) { - res.body.should.eql(document); + var body = res.body; + expect(body).to.eql(document); }); }); }); describe('An LRS\'s State API rejects a GET request with "registration" as a parameter if it is not a UUID with error code 400 Bad Request (format, 7.4.table1.row3.a)', function () { - var parameters = helper.buildState(), - invalidTypes = [1, true, 'not UUID bruh']; + var invalidTypes = [1, true, 'not UUID bruh']; invalidTypes.forEach(function (type) { it('Should reject GET with "registration" with type ' + type, function () { + var parameters = helper.buildState(); parameters.registration = type; - return sendRequest('get', '/activities/state', parameters, undefined, 400); + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 400); }); }); }); @@ -513,22 +520,23 @@ it('An LRS\'s State API can process a GET request with "stateId" as a parameter (multiplicity, 7.4.table1.row3.b, 7.4.table2.row3.b) (multiplicity, 7.4.table1.row1.b)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); - return sendRequest('post', '/activities/state', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204) .then(function () { - return sendRequest('get', '/activities/state', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 200) .then(function (res) { - res.body.should.eql(document); + var body = res.body; + expect(body).to.eql(document); }) }); }); - describe('An LRS\'s State API rejects a GET request with "stateId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.4.table1.row1.a)', function () { - var parameters = helper.buildState(), - invalidTypes = [1, true, {}, undefined]; + describe('An LRS\'s State API rejects a GET request with "stateId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.4.table1.row1.a)', function () { + var invalidTypes = [{ key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject GET with "stateId" with type ' + type, function () { + var parameters = helper.buildState(); parameters.stateId = type; - return sendRequest('get', '/activities/state', parameters, undefined, 400); + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 400); }); }); }); @@ -537,11 +545,12 @@ var parameters = helper.buildState(), document = helper.buildDocument(); parameters.since = new Date(Date.now() - 60 * 1000); // Date 1 minute ago - return sendRequest('post', '/activities/state', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204) .then(function () { - return sendRequest('get', '/activities/state', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 200) .then(function (res) { - res.body.should.eql(document); + var body = res.body; + expect(body).to.eql(document); }); }); }); @@ -549,17 +558,18 @@ it('An LRS\'s State API rejects a GET request with "since" as a parameter if it is not a "TimeStamp", with error code 400 Bad Request (format, 7.4.table2.row4.a)', function () { var parameters = helper.buildState(); parameters.since = 'not a timestamp dog'; - return sendRequest('get', '/activities/state', parameters, undefined, 400); + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 400); }); it('An LRS\'s State API upon processing a successful GET request with a valid "stateId" as a parameter returns the document satisfying the requirements of the GET and code 200 OK (7.4.b)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); - return sendRequest('post', '/activities/state', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204) .then(function () { - return sendRequest('get', '/activities/state', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 200) .then(function (res) { - res.body.should.eql(document); + var body = res.body; + expect(body).to.eql(document); }); }); }); @@ -568,32 +578,31 @@ it('An LRS\'s State API upon processing a successful GET request without "stateId" as a parameter returns an array of ids of state data documents satisfying the requirements of the GET and code 200 OK (7.4.c)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); - return sendRequest('post', '/activities/state', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204) .then(function () { delete parameters.stateId; - return sendRequest('get', '/activities/state', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 200) .then(function (res) { - res.body.should.be.instanceOf(Array); + var body = res.body; + expect(body).to.be.an('array'); }); }); }); it('An LRS\'s returned array of ids from a successful GET request all refer to documents stored after the TimeStamp in the "since" parameter of the GET request (7.4.table2.row4)', function () { - var parameters = helper.buildState(), - document = helper.buildDocument(), - anotherDocument = helper.buildDocument(); - var anotherParameters = helper.clone(parameters); - anotherParameters.stateId = helper.generateUUID(); - return sendRequest('post', '/activities/state', parameters, document, 204) + var document = helper.buildDocument(); + return sendRequest('post', helper.getEndpointActivitiesState(), helper.buildState(), document, 204) .then(function () { - return sendRequest('post', '/activities/state', anotherParameters, anotherDocument, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), helper.buildState(), document, 204) .then(function () { + var parameters = helper.buildState(); delete parameters.stateId; parameters.since = new Date(Date.now() - 1000); - return sendRequest('get', '/activities/state', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 200) .then(function (res) { - res.body.should.be.instanceOf(Array); - res.body.length.should.greaterThan(0); + var body = res.body; + expect(body).to.be.an('array'); + expect(body).to.have.length.above(1); }); }); }); @@ -602,25 +611,25 @@ it('An LRS\'s State API accepts DELETE requests (7.4)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); - return sendRequest('post', '/activities/state', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204) .then(function () { - return sendRequest('delete', '/activities/state', parameters, undefined, 204); + return sendRequest('delete', helper.getEndpointActivitiesState(), parameters, undefined, 204); }); }); it('An LRS\'s State API rejects a DELETE request without "activityId" as a parameter with error code 400 Bad Request (multiplicity, 7.4.table1.row1.b)', function () { var parameters = helper.buildState(); delete parameters.activityId; - return sendRequest('delete', '/activities/state', parameters, undefined, 400); + return sendRequest('delete', helper.getEndpointActivitiesState(), parameters, undefined, 400); }); - describe('An LRS\'s State API rejects a DELETE request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.4.table1.row1.a)', function () { - var parameters = helper.buildState(), - invalidTypes = [1, true, {}, undefined]; + describe('An LRS\'s State API rejects a DELETE request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.4.table1.row1.a)', function () { + var invalidTypes = [1, true, { key: 'value'}, undefined]; invalidTypes.forEach(function (type) { it('Should reject DELETE with "activityId" with type ' + type, function () { + var parameters = helper.buildState(); parameters.activityId = type; - return sendRequest('delete', '/activities/state', parameters, undefined, 400); + return sendRequest('delete', helper.getEndpointActivitiesState(), parameters, undefined, 400); }); }); }); @@ -628,16 +637,16 @@ it('An LRS\'s State API rejects a DELETE request without "agent" as a parameter with error code 400 Bad Request (multiplicity, 7.4.table1.row2.b)', function () { var parameters = helper.buildState(); delete parameters.agent; - return sendRequest('delete', '/activities/state', parameters, undefined, 400); + return sendRequest('delete', helper.getEndpointActivitiesState(), parameters, undefined, 400); }); describe('An LRS\'s State API rejects a DELETE request with "agent" as a parameter if it is not in JSON format with error code 400 Bad Request (format, 7.4.table1.row2.a)', function () { - var parameters = helper.buildState(), - invalidTypes = [1, true, 'not JSON son', undefined]; + var invalidTypes = [1, true, 'not JSON son', undefined]; invalidTypes.forEach(function (type) { it('Should reject DELETE with "agent" with type ' + type, function () { + var parameters = helper.buildState(); parameters.activityId = type; - return sendRequest('delete', '/activities/state', parameters, undefined, 400); + return sendRequest('delete', helper.getEndpointActivitiesState(), parameters, undefined, 400); }); }); }); @@ -646,19 +655,19 @@ var parameters = helper.buildState(), document = helper.buildDocument(); parameters.registration = helper.generateUUID(); - return sendRequest('post', '/activities/state', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204) .then(function () { - return sendRequest('delete', '/activities/state', parameters, undefined, 204); + return sendRequest('delete', helper.getEndpointActivitiesState(), parameters, undefined, 204); }); }); describe('An LRS\'s State API rejects a DELETE request with "registration" as a parameter if it is not a UUID with error code 400 Bad Request (format, 7.4.table1.row3.a)', function () { - var parameters = helper.buildState(), - invalidTypes = [1, true, 'not UUID son']; + var invalidTypes = [1, true, 'not UUID son']; invalidTypes.forEach(function (type) { it('Should reject DELETE with "registration" with type ' + type, function () { + var parameters = helper.buildState(); parameters.registration = type; - return sendRequest('delete', '/activities/state', parameters, undefined, 400); + return sendRequest('delete', helper.getEndpointActivitiesState(), parameters, undefined, 400); }); }); }); @@ -666,19 +675,19 @@ it('An LRS\'s State API can process a DELETE request with "stateId" as a parameter (multiplicity, 7.4.table1.row3.b, 7.4.table2.row3.b) (multiplicity, 7.4.table1.row1.b)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); - return sendRequest('post', '/activities/state', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204) .then(function () { - return sendRequest('delete', '/activities/state', parameters, undefined, 204); + return sendRequest('delete', helper.getEndpointActivitiesState(), parameters, undefined, 204); }); }); - describe('An LRS\'s State API rejects a DELETE request with "stateId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.4.table1.row1.a)', function () { - var parameters = helper.buildState(), - invalidTypes = [1, true, {}, undefined]; + describe('An LRS\'s State API rejects a DELETE request with "stateId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.4.table1.row1.a)', function () { + var invalidTypes = [{ key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject DELETE with "stateId" with type ' + type, function () { + var parameters = helper.buildState(); parameters.stateId = type; - return sendRequest('delete', '/activities/state', parameters, undefined, 400); + return sendRequest('delete', helper.getEndpointActivitiesState(), parameters, undefined, 400); }); }); }); @@ -687,19 +696,19 @@ var parameters = helper.buildState(), document = helper.buildDocument(); parameters.since = new Date(); - return sendRequest('post', '/activities/state', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204) .then(function () { - return sendRequest('delete', '/activities/state', parameters, undefined, 204); + return sendRequest('delete', helper.getEndpointActivitiesState(), parameters, undefined, 204); }); }); - describe('An LRS\'s State API rejects a DELETE request with "since" as a parameter if it is not a "TimeStamp", with error code 400 Bad Request (format, 7.4.table2.row4.a) **And this would follow...**', function (done) { - var parameters = helper.buildState(), - invalidTypes = [1, true, {}]; + describe('An LRS\'s State API rejects a DELETE request with "since" as a parameter if it is not a "TimeStamp", with error code 400 Bad Request (format, 7.4.table2.row4.a) **And this would follow...**', function () { + var invalidTypes = [1, true]; invalidTypes.forEach(function (type) { it('Should reject DELETE with "since" with type ' + type, function () { + var parameters = helper.buildState(); parameters.since = type; - return sendRequest('delete', '/activities/state', parameters, undefined, 400); + return sendRequest('delete', helper.getEndpointActivitiesState(), parameters, undefined, 400); }); }); }); @@ -707,78 +716,98 @@ it('An LRS\'s State API upon processing a successful DELETE request with a valid "stateId" as a parameter deletes the document satisfying the requirements of the DELETE and returns code 204 No Content (7.4.b)', function () { var parameters = helper.buildState(), document = helper.buildDocument(); - return sendRequest('post', '/activities/state', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesState(), parameters, document, 204) .then(function () { - return sendRequest('delete', '/activities/state', parameters, undefined, 204); + return sendRequest('delete', helper.getEndpointActivitiesState(), parameters, undefined, 204); }); }); //+* NOTE: **There is no requirement here that the LRS reacts to the "since" parameter in the case of a GET request with valid "stateId" - this is intentional** it('An LRS\'s State API upon processing a successful DELETE request without "stateId" as a parameter deletes documents satisfying the requirements of the DELETE and code 200 OK (7.4.d)', function () { - // TODO Spec doesn't state this should be 200 - var parameters = helper.buildState(), - document = helper.buildDocument(); - return sendRequest('post', '/activities/state', parameters, document, 204) + var parameters = helper.buildState(); + delete parameters.stateId; + + return sendRequest('post', helper.getEndpointActivitiesState(), helper.buildState(), helper.buildDocument(), 204) .then(function () { - delete parameters.stateId; - return sendRequest('delete', '/activities/state', parameters, undefined, 200); + return sendRequest('post', helper.getEndpointActivitiesState(), helper.buildState(), helper.buildDocument(), 204) + .then(function () { + return sendRequest('delete', helper.getEndpointActivitiesState(), parameters, undefined, 204) + .then(function () { + return sendRequest('get', helper.getEndpointActivitiesState(), parameters, undefined, 200) + .then(function (res) { + var body = res.body; + expect(body).to.be.an('array'); + expect(body).to.have.length(0); + }); + }); + }); }); }); it('An LRS\'s Activities API accepts GET requests (7.5)', function () { var parameters = helper.buildActivity(); - return sendRequest('get', '/activities', parameters, undefined, 200) - .then(function (res) { - // TODO Why Statement DAL? - new Error('Implement Test'); - }); + return sendRequest('get', helper.getEndpointActivities(), parameters, undefined, 200); }); it('An LRS\'s Activities API rejects a GET request without "activityId" as a parameter with error code 400 Bad Request (multiplicity, 7.5.table1.row1.b)', function () { - var parameters = helper.buildActivity(), - document = helper.buildDocument(); - delete parameters.activityId; - return sendRequest('get', '/activities', parameters, document, 400); + return sendRequest('get', helper.getEndpointActivities(), undefined, undefined, 400); }); - it('An LRS\'s Activities API rejects a GET request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table1.row1.a)', function () { - var parameters = helper.buildActivity(), - invalidTypes = [1, true, {}]; + it('An LRS\'s Activities API rejects a GET request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table1.row1.a)', function () { + var invalidTypes = [1, true, { key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject GET with "since" with type ' + type, function () { + var parameters = helper.buildActivity(); parameters.since = type; - return sendRequest('get', '/activities', parameters, undefined, 400); + return sendRequest('get', helper.getEndpointActivities(), parameters, undefined, 400); }); }); }); it('An LRS\'s Activities API upon processing a successful GET request returns the complete Activity Object (7.5)', function () { - var parameters = helper.buildActivity(), - document = helper.buildDocument(); - return sendRequest('get', '/activities', parameters, document, 200); + var templates = [ + {statement: '{{statements.object_activity}}'}, + {object: '{{activities.default}}'} + ]; + var data = createFromTemplate(templates); + var statement = data.statement; + statement.object.id = 'http://www.example.com/verify/complete/34534'; + + return sendRequest('post', helper.getEndpointStatements(), undefined, [statement], 200) + .then(function () { + var parameters = { + activityId: statement.object.id + }; + return sendRequest('get', helper.getEndpointActivities(), parameters, undefined, 200) + .then(function (res) { + var activity = res.body; + expect(activity).to.be.ok; + expect(activity).to.eql(statement.object); + }); + }); }); it('An LRS\'s Activity Profile API accepts PUT requests (7.5)', function () { var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); - return sendRequest('put', '/activities/profile', parameters, document, 204); + return sendRequest('put', helper.getEndpointActivitiesProfile(), parameters, document, 204); }); it('An LRS\'s Activity Profile API rejects a PUT request without "activityId" as a parameter with error code 400 Bad Request (multiplicity, 7.5.table2.row1.c)', function () { var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); delete parameters.activityId; - return sendRequest('put', '/activities/profile', parameters, document, 400); + return sendRequest('put', helper.getEndpointActivitiesProfile(), parameters, document, 400); }); - describe('An LRS\'s Activity Profile API API rejects a PUT request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table2.row2.a)', function () { - var parameters = helper.buildActivityProfile(), - document = helper.buildDocument(), - invalidTypes = [1, true, {}]; + describe('An LRS\'s Activity Profile API API rejects a PUT request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table2.row2.a)', function () { + var document = helper.buildDocument(), + invalidTypes = [1, true, { key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject PUT with "activityId" with type ' + type, function () { + var parameters = helper.buildActivityProfile(); parameters.activityId = type; - return sendRequest('put', '/activities/profile', parameters, document, 400); + return sendRequest('put', helper.getEndpointActivitiesProfile(), parameters, document, 400); }); }); }); @@ -787,17 +816,17 @@ var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); delete parameters.profileId; - return sendRequest('put', '/activities/profile', parameters, document, 400); + return sendRequest('put', helper.getEndpointActivitiesProfile(), parameters, document, 400); }); - describe('An LRS\'s Activity Profile API rejects a PUT request with "profileId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table2.row2.a)', function () { - var parameters = helper.buildActivityProfile(), - document = helper.buildDocument(), - invalidTypes = [1, true, {}]; + describe('An LRS\'s Activity Profile API rejects a PUT request with "profileId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table2.row2.a)', function () { + var document = helper.buildDocument(), + invalidTypes = [{ key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject PUT with "profileId" with type ' + type, function () { + var parameters = helper.buildActivityProfile(); parameters.profileId = type; - return sendRequest('put', '/activities/profile', parameters, document, 400); + return sendRequest('put', helper.getEndpointActivitiesProfile(), parameters, document, 400); }); }); }); @@ -805,30 +834,30 @@ it('An LRS\'s Activity Profile API upon processing a successful PUT request returns code 204 No Content (7.5.b)', function () { var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); - return sendRequest('put', '/activities/profile', parameters, document, 204); + return sendRequest('put', helper.getEndpointActivitiesProfile(), parameters, document, 204); }); it('An LRS\'s Activity Profile API accepts POST requests (7.5)', function () { var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); - return sendRequest('post', '/activities/profile', parameters, document, 204); + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 204); }); it('An LRS\'s Activity Profile API rejects a POST request without "activityId" as a parameter with error code 400 Bad Request (multiplicity, 7.5.table2.row1.c)', function () { var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); delete parameters.activityId; - return sendRequest('post', '/activities/profile', parameters, document, 400); + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 400); }); - describe('An LRS\'s Activity Profile API rejects a POST request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table2.row2.a)', function () { - var parameters = helper.buildActivityProfile(), - document = helper.buildDocument(), - invalidTypes = [1, true, {}]; + describe('An LRS\'s Activity Profile API rejects a POST request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table2.row2.a)', function () { + var document = helper.buildDocument(), + invalidTypes = [1, true, { key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject POST with "activityId" with type ' + type, function () { + var parameters = helper.buildActivityProfile(); parameters.activityId = type; - return sendRequest('post', '/activities/profile', parameters, document, 400); + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 400); }); }); }); @@ -837,17 +866,17 @@ var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); delete parameters.profileId; - return sendRequest('post', '/activities/profile', parameters, document, 400); + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 400); }); - describe('An LRS\'s Activity Profile API rejects a POST request with "profileId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table2.row2.a)', function () { - var parameters = helper.buildActivityProfile(), - document = helper.buildDocument(), - invalidTypes = [1, true, {}]; + describe('An LRS\'s Activity Profile API rejects a POST request with "profileId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table2.row2.a)', function () { + var document = helper.buildDocument(), + invalidTypes = [{ key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject POST with "profileId" with type ' + type, function () { + var parameters = helper.buildActivityProfile(); parameters.profileId = type; - return sendRequest('post', '/activities/profile', parameters, document, 400); + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 400); }); }); }); @@ -855,27 +884,27 @@ it('An LRS\'s Activity Profile API upon processing a successful POST request returns code 204 No Content (7.5.b)', function () { var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); - return sendRequest('post', '/activities/profile', parameters, document, 204); + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 204); }); it('An LRS\'s Activity Profile API accepts DELETE requests (7.5)', function () { var parameters = helper.buildActivityProfile(); - return sendRequest('delete', '/activities/profile', parameters, undefined, 204); + return sendRequest('delete', helper.getEndpointActivitiesProfile(), parameters, undefined, 204); }); it('An LRS\'s Activity Profile API rejects a DELETE request without "activityId" as a parameter with error code 400 Bad Request (multiplicity, 7.5.table2.row1.c)', function () { var parameters = helper.buildActivityProfile(); delete parameters.activityId; - return sendRequest('delete', '/activities/profile', parameters, undefined, 400); + return sendRequest('delete', helper.getEndpointActivitiesProfile(), parameters, undefined, 400); }); - describe('An LRS\'s Activity Profile API rejects a DELETE request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table2.row2.a)', function () { - var parameters = helper.buildActivityProfile(), - invalidTypes = [1, true, {}]; + describe('An LRS\'s Activity Profile API rejects a DELETE request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table2.row2.a)', function () { + var invalidTypes = [1, true, { key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject DELETE with "activityId" with type ' + type, function () { + var parameters = helper.buildActivityProfile(); parameters.activityId = type; - return sendRequest('delete', '/activities/profile', parameters, undefined, 400); + return sendRequest('delete', helper.getEndpointActivitiesProfile(), parameters, undefined, 400); }); }); }); @@ -883,16 +912,16 @@ it('An LRS\'s Activity Profile API rejects a DELETE request without "profileId" as a parameter with error code 400 Bad Request (multiplicity, 7.5.table2.row1.c)', function () { var parameters = helper.buildActivityProfile(); delete parameters.profileId; - return sendRequest('delete', '/activities/profile', parameters, undefined, 400); + return sendRequest('delete', helper.getEndpointActivitiesProfile(), parameters, undefined, 400); }); - describe('An LRS\'s Activity Profile API rejects a DELETE request with "profileId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table2.row2.a)', function () { - var parameters = helper.buildActivityProfile(), - invalidTypes = [1, true, {}]; + describe('An LRS\'s Activity Profile API rejects a DELETE request with "profileId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table2.row2.a)', function () { + var invalidTypes = [{ key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject DELETE with "profileId" with type ' + type, function () { + var parameters = helper.buildActivityProfile(); parameters.profileId = type; - return sendRequest('delete', '/activities/profile', parameters, undefined, 400); + return sendRequest('delete', helper.getEndpointActivitiesProfile(), parameters, undefined, 400); }); }); }); @@ -900,63 +929,56 @@ it('An LRS\'s Activity Profile API upon processing a successful DELETE request deletes the associated profile and returns code 204 No Content (7.5.b)', function () { var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); - return sendRequest('delete', '/activities/profile', parameters, document, 204); + return sendRequest('delete', helper.getEndpointActivitiesProfile(), parameters, document, 204); }); it('An LRS\'s Activity Profile API accepts GET requests (7.5)', function () { var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); - return sendRequest('post', '/activities/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 204) .then(function () { - return sendRequest('get', '/activities/profile', parameters, undefined, 200); + return sendRequest('get', helper.getEndpointActivitiesProfile(), parameters, undefined, 200); }); }); it('An LRS\'s Activity Profile API rejects a GET request without "activityId" as a parameter with error code 400 Bad Request (multiplicity, 7.5.table2.row1.c)', function () { var parameters = helper.buildActivityProfile(); delete parameters.activityId; - return sendRequest('get', '/activities/profile', parameters, undefined, 400); + return sendRequest('get', helper.getEndpointActivitiesProfile(), parameters, undefined, 400); }); - describe('An LRS\'s Activity Profile API rejects a GET request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table2.row1.a)', function () { - var parameters = helper.buildActivityProfile(), - invalidTypes = [1, true, {}]; + describe('An LRS\'s Activity Profile API rejects a GET request with "activityId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.5.table2.row1.a)', function () { + var invalidTypes = [1, true, { key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject GET with "activityId" with type ' + type, function () { + var parameters = helper.buildActivityProfile(); parameters.activityId = type; - return sendRequest('get', '/activities/profile', parameters, undefined, 400); + return sendRequest('get', helper.getEndpointActivitiesProfile(), parameters, undefined, 400); }); }); }); - describe('An LRS\'s Activity Profile API rejects a GET request with "agent" as a parameter if it is not in JSON format with error code 400 Bad Request (format, 7.4.table2.row2.a)', function () { - var parameters = helper.buildActivityProfile(), - invalidTypes = [1, true, 'not JSON']; - invalidTypes.forEach(function (type) { - it('Should reject GET with "agent" with type ' + type, function () { - parameters.agent = type; - return sendRequest('get', '/activities/profile', parameters, undefined, 400); - }); - }); + it.skip('An LRS\'s Activity Profile API rejects a GET request with "agent" as a parameter if it is not in JSON format with error code 400 Bad Request (format, 7.4.table2.row2.a)', function () { + done(new Error('Invalid Test since agent is not valid parameter')); }); it('An LRS\'s Activity Profile API can process a GET request with "since" as a parameter (multiplicity, 7.5.table3.row2.c, 7.5.table3.row2.b)', function () { var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); parameters.since = new Date(Date.now() - 1000); - return sendRequest('post', '/activities/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 204) .then(function () { - return sendRequest('get', '/activities/profile', parameters, undefined, 200); + return sendRequest('get', helper.getEndpointActivitiesProfile(), parameters, undefined, 200); }); }); describe('An LRS\'s Activity Profile API rejects a GET request with "since" as a parameter if it is not a "TimeStamp", with error code 400 Bad Request (format, 7.5.table3.row2.a)', function () { - var parameters = helper.buildActivityProfile(), - invalidTypes = [1, true, 'not Timestamp bruh']; + var invalidTypes = [1, true, 'not Timestamp bruh']; invalidTypes.forEach(function (type) { it('Should reject GET with "since" with type ' + type, function () { + var parameters = helper.buildActivityProfile(); parameters.since = type; - return sendRequest('get', '/activities/profile', parameters, undefined, 400); + return sendRequest('get', helper.getEndpointActivitiesProfile(), parameters, undefined, 400); }); }); }); @@ -964,11 +986,12 @@ it('An LRS\'s Activity Profile API upon processing a successful GET request with a valid "profileId" as a parameter returns the document satisfying the requirements of the GET and code 200 OK (7.5.c)', function () { var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); - return sendRequest('post', '/activities/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 204) .then(function () { - return sendRequest('get', '/activities/profile', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointActivitiesProfile(), parameters, undefined, 200) .then(function (res) { - res.body.should.eql(document); + var body = res.body; + expect(body).to.eql(document); }) }); }); @@ -976,13 +999,14 @@ it('An LRS\'s Activity Profile API upon processing a successful GET request without "profileId" as a parameter returns an array of ids of activity profile documents satisfying the requirements of the GET and code 200 OK (7.5.d)', function () { var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); - return sendRequest('post', '/activities/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 204) .then(function () { delete parameters.profileId; - return sendRequest('get', '/activities/profile', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointActivitiesProfile(), parameters, undefined, 200) .then(function (res) { - res.body.should.be.instanceOf(Array); - res.body.length.should.be.greaterThan(1); + var body = res.body; + expect(body).to.be.an('array'); + expect(body).to.be.length.above(0); }); }); }); @@ -990,66 +1014,66 @@ it('An LRS\'s returned array of ids from a successful GET request all refer to documents stored after the TimeStamp in the "since" parameter of the GET request if such a parameter was present (7.5.table3.row2)', function () { var parameters = helper.buildActivityProfile(), document = helper.buildDocument(); - return sendRequest('post', '/activities/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointActivitiesProfile(), parameters, document, 204) .then(function () { delete parameters.profileId; parameters.since = new Date(Date.now() - 1000); // Date 1 second ago - return sendRequest('get', '/activities/profile', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointActivitiesProfile(), parameters, undefined, 200) .then(function (res) { - res.body.should.be.instanceOf(Array); - res.body.length.should.be.greaterThan(1); + var body = res.body; + expect(body).to.be.an('array'); + expect(body).to.be.length.above(0); }); }); }); - it('An LRS\'s Agents API accepts GET requests (7.6)', function (done) { + it.skip('An LRS\'s Agents API accepts GET requests (7.6)', function (done) { // TODO Fix this test - var parameters = buildAgent(); - //return sendRequest('get', '/agents', parameters, undefined, 200) + //var parameters = buildAgent(); + //return sendRequest('get', helper.getEndpointAgents(), parameters, undefined, 200) // .then(function (res) { // res.body; // }); done(new Error('Implement Test')); }); - it('An LRS\'s Agents API rejects a GET request without "agent" as a parameter with error code 400 Bad Request (multiplicity, 7.6.table2.row1.c)', function (done) { + it.skip('An LRS\'s Agents API rejects a GET request without "agent" as a parameter with error code 400 Bad Request (multiplicity, 7.6.table2.row1.c)', function (done) { done(new Error('Implement Test')); }); - it('An LRS\'s Agents API rejects a GET request with "agent" as a parameter if it is a valid (in structure) Agent with error code 400 Bad Request (format, 7.6.table2.row1.a)', function (done) { + it.skip('An LRS\'s Agents API rejects a GET request with "agent" as a parameter if it is a valid (in structure) Agent with error code 400 Bad Request (format, 7.6.table2.row1.a)', function (done) { done(new Error('Implement Test')); }); - it('An LRS\'s Agents API upon processing a successful GET request returns a Person Object if the "agent" parameter can be found in the LRS and code 200 OK (7.6.c, 7.6.d)', function (done) { + it.skip('An LRS\'s Agents API upon processing a successful GET request returns a Person Object if the "agent" parameter can be found in the LRS and code 200 OK (7.6.c, 7.6.d)', function (done) { done(new Error('Implement Test')); }); - it('An LRS\'s Agents API upon processing a successful GET request returns a Person Object based on matched data from the "agent" parameter and code 200 OK (7.6.d)', function (done) { + it.skip('An LRS\'s Agents API upon processing a successful GET request returns a Person Object based on matched data from the "agent" parameter and code 200 OK (7.6.d)', function (done) { done(new Error('Implement Test')); }); - it('An LRS\'s Agent Profile API accepts PUT requests (7.6)', function () { var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); - return sendRequest('put', '/agents/profile', parameters, document, 204); + return sendRequest('put', helper.getEndpointAgentsProfile(), parameters, document, 204); }); it('An LRS\'s Agent Profile API rejects a PUT request without "agent" as a parameter with error code 400 Bad Request (multiplicity, 7.6.table3.row1.c)', function () { var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); delete parameters.agent; - return sendRequest('put', '/agents/profile', parameters, document, 400); + return sendRequest('put', helper.getEndpointAgentsProfile(), parameters, document, 400); }); - describe('An LRS\'s Agent Profile API rejects a PUT request with "agent" as a parameter if it is not an Agent Object with error code 400 Bad Request (format, 7.6.table3.row1.a)', function () { - var parameters = helper.buildAgentProfile(), - document = helper.buildDocument(), - invalidTypes = [1, true, 'not Agent bruh', {}]; + describe('An LRS\'s Agent Profile API rejects a PUT request with "agent" as a parameter if it is not an Agent Object with error code 400 Bad Request (format, 7.6.table3.row1.a)', function () { + var document = helper.buildDocument(), + invalidTypes = [1, true, 'not Agent bruh', { key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject PUT with "agent" with type ' + type, function () { + var parameters = helper.buildAgentProfile(); parameters.agent = type; - return sendRequest('put', '/agents/profile', parameters, document, 400); + return sendRequest('put', helper.getEndpointAgentsProfile(), parameters, document, 400); }); }); }); @@ -1058,16 +1082,16 @@ var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); delete parameters.profileId; - return sendRequest('put', '/agents/profile', parameters, document, 400); + return sendRequest('put', helper.getEndpointAgentsProfile(), parameters, document, 400); }); - describe('An LRS\'s Agent Profile API rejects a PUT request with "profileId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.6.table3.row2.a)', function () { - var parameters = helper.buildAgentProfile(), - invalidTypes = [1, true, {}]; + describe('An LRS\'s Agent Profile API rejects a PUT request with "profileId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.6.table3.row2.a)', function () { + var invalidTypes = [{ key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject PUT with "profileId" with type ' + type, function () { + var parameters = helper.buildAgentProfile(); parameters.profileId = type; - return sendRequest('put', '/agents/profile', parameters, undefined, 400); + return sendRequest('put', helper.getEndpointAgentsProfile(), parameters, undefined, 400); }); }); }); @@ -1075,30 +1099,30 @@ it('An LRS\'s Agent Profile API upon processing a successful PUT request returns code 204 No Content (7.6.e)', function () { var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); - return sendRequest('put', '/agents/profile', parameters, document, 204); + return sendRequest('put', helper.getEndpointAgentsProfile(), parameters, document, 204); }); it('An LRS\'s Agent Profile API accepts POST requests (7.6)', function () { var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); - return sendRequest('post', '/agents/profile', parameters, document, 204); + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 204); }); it('An LRS\'s Agent Profile API rejects a POST request without "agent" as a parameter with error code 400 Bad Request (multiplicity, 7.6.table3.row1.c)', function () { var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); delete parameters.agent; - return sendRequest('post', '/agents/profile', parameters, document, 400); + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 400); }); - it('An LRS\'s Agent Profile API rejects a POST request with "agent" as a parameter if it is not an Agent Object with error code 400 Bad Request (format, 7.6.table3.row1.a)', function () { - var parameters = helper.buildAgentProfile(), - document = helper.buildDocument(), - invalidTypes = [1, true, {}]; + it('An LRS\'s Agent Profile API rejects a POST request with "agent" as a parameter if it is not an Agent Object with error code 400 Bad Request (format, 7.6.table3.row1.a)', function () { + var document = helper.buildDocument(), + invalidTypes = [1, true, { key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject POST with "agent" with type ' + type, function () { + var parameters = helper.buildAgentProfile(); parameters.agent = type; - return sendRequest('post', '/agents/profile', parameters, document, 400); + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 400); }); }); }); @@ -1107,17 +1131,17 @@ var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); delete parameters.profileId; - return sendRequest('post', '/agents/profile', parameters, document, 400); + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 400); }); - describe('An LRS\'s Agent Profile API rejects a POST request with "profileId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.6.table3.row2.a)', function () { - var parameters = helper.buildAgentProfile(), - document = helper.buildDocument(), - invalidTypes = [1, true, {}]; + describe('An LRS\'s Agent Profile API rejects a POST request with "profileId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.6.table3.row2.a)', function () { + var document = helper.buildDocument(), + invalidTypes = [{ key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject POST with "profileId" with type ' + type, function () { + var parameters = helper.buildAgentProfile(); parameters.profileId = type; - return sendRequest('post', '/agents/profile', parameters, document, 400); + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 400); }); }); }); @@ -1125,28 +1149,28 @@ it('An LRS\'s Agent Profile API upon processing a successful POST request returns code 204 No Content (7.6.e)', function () { var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); - return sendRequest('post', '/agents/profile', parameters, document, 204); + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 204); }); it('An LRS\'s Agent Profile API accepts DELETE requests (7.6)', function () { var parameters = helper.buildAgentProfile(); - return sendRequest('delete', '/agents/profile', parameters, undefined, 204); + return sendRequest('delete', helper.getEndpointAgentsProfile(), parameters, undefined, 204); }); it('An LRS\'s Agent Profile API rejects a DELETE request without "agent" as a parameter with error code 400 Bad Request (multiplicity, 7.6.table3.row1.c)', function () { var parameters = helper.buildAgentProfile(); delete parameters.agent; - return sendRequest('delete', '/agents/profile', parameters, undefined, 400); + return sendRequest('delete', helper.getEndpointAgentsProfile(), parameters, undefined, 400); }); - describe('An LRS\'s Agent Profile API rejects a DELETE request with "agent" as a parameter if it is not an Agent Object with error code 400 Bad Request (format, 7.6.table3.row1.a)', function () { - var parameters = helper.buildAgentProfile(), - document = helper.buildDocument(), - invalidTypes = [1, true, {}]; + describe('An LRS\'s Agent Profile API rejects a DELETE request with "agent" as a parameter if it is not an Agent Object with error code 400 Bad Request (format, 7.6.table3.row1.a)', function () { + var document = helper.buildDocument(), + invalidTypes = [1, true, { key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject DELETE with "agent" with type ' + type, function () { + var parameters = helper.buildAgentProfile(); parameters.agent = type; - return sendRequest('delete', '/agents/profile', parameters, document, 400); + return sendRequest('delete', helper.getEndpointAgentsProfile(), parameters, document, 400); }); }); }); @@ -1154,17 +1178,17 @@ it('An LRS\'s Agent Profile API rejects a DELETE request without "profileId" as a parameter with error code 400 Bad Request (multiplicity, 7.6.table3.row2.c)', function () { var parameters = helper.buildAgentProfile(); delete parameters.profileId; - return sendRequest('delete', '/agents/profile', parameters, undefined, 400); + return sendRequest('delete', helper.getEndpointAgentsProfile(), parameters, undefined, 400); }); - describe('An LRS\'s Agent Profile API rejects a DELETE request with "profileId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.6.table3.row2.a)', function () { - var parameters = helper.buildAgentProfile(), - document = helper.buildDocument(), - invalidTypes = [1, true, {}]; + describe('An LRS\'s Agent Profile API rejects a DELETE request with "profileId" as a parameter if it is not type "String" with error code 400 Bad Request (format, 7.6.table3.row2.a)', function () { + var document = helper.buildDocument(), + invalidTypes = [1, true, { key: 'value'}]; invalidTypes.forEach(function (type) { it('Should reject DELETE with "profileId" with type ' + type, function () { + var parameters = helper.buildAgentProfile(); parameters.agent = type; - return sendRequest('delete', '/agents/profile', parameters, document, 400); + return sendRequest('delete', helper.getEndpointAgentsProfile(), parameters, document, 400); }); }); }); @@ -1172,18 +1196,18 @@ it('An LRS\'s Agent Profile API upon processing a successful DELETE request deletes the associated profile and returns code 204 No Content (7.6.e)', function () { var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); - return sendRequest('post', '/agents/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 204) .then(function () { - return sendRequest('delete', '/agents/profile', parameters, undefined, 204); + return sendRequest('delete', helper.getEndpointAgentsProfile(), parameters, undefined, 204) }); }); it('An LRS\'s Agent Profile API accepts GET requests (7.6)', function () { var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); - return sendRequest('post', '/agents/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 204) .then(function () { - return sendRequest('get', '/agents/profile', parameters, undefined, 200); + return sendRequest('get', helper.getEndpointAgentsProfile(), parameters, undefined, 200); }); }); @@ -1191,17 +1215,17 @@ var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); delete parameters.agent; - return sendRequest('get', '/agents/profile', parameters, document, 400); + return sendRequest('get', helper.getEndpointAgentsProfile(), parameters, document, 400); }); describe('An LRS\'s Agent Profile API rejects a GET request with "agent" as a parameter if it is not an Actor Object with error code 400 Bad Request (format, 7.6.table3.row1.c, 7.6.table4.row1.c)', function () { - var parameters = helper.buildAgentProfile(), - document = helper.buildDocument(), + var document = helper.buildDocument(), invalidTypes = [1, true, {"not_actor": "yup"}, 'not Actor']; invalidTypes.forEach(function (type) { it('Should reject GET with "agent" with type ' + type, function () { + var parameters = helper.buildAgentProfile(); parameters.agent = type; - return sendRequest('get', '/agents/profile', parameters, document, 400); + return sendRequest('get', helper.getEndpointAgentsProfile(), parameters, document, 400); }); }); }); @@ -1210,21 +1234,21 @@ var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); parameters.since = new Date(); - return sendRequest('post', '/agents/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 204) .then(function () { parameters.since = new Date(Date.now() - 1000); - return sendRequest('get', '/agents/profile', parameters, undefined, 200); + return sendRequest('get', helper.getEndpointAgentsProfile(), parameters, undefined, 200); }); }); describe('An LRS\'s Agent Profile API rejects a GET request with "since" as a parameter if it is not a "TimeStamp", with error code 400 Bad Request (format, 7.6.table4.row2.a)', function () { - var parameters = helper.buildAgentProfile(), - document = helper.buildDocument(), - invalidTypes = [1, true, {}, 'not timestamp']; + var document = helper.buildDocument(), + invalidTypes = [1, true, { key: 'value'}, 'not timestamp']; invalidTypes.forEach(function (type) { it('Should reject GET with "since" with type ' + type, function () { + var parameters = helper.buildAgentProfile(); parameters.agent = type; - return sendRequest('get', '/agents/profile', parameters, document, 400); + return sendRequest('get', helper.getEndpointAgentsProfile(), parameters, document, 400); }); }); }); @@ -1232,11 +1256,12 @@ it('An LRS\'s Agent Profile API upon processing a successful GET request with a valid "profileId" as a parameter returns the document satisfying the requirements of the GET and code 200 OK (7.6, 7.6.f)', function () { var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); - return sendRequest('post', '/agents/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 204) .then(function () { - return sendRequest('get', '/agents/profile', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointAgentsProfile(), parameters, undefined, 200) .then(function (res) { - res.body.should.eql(document); + var body = res.body; + expect(body).to.eql(document); }) }); }); @@ -1244,13 +1269,13 @@ it('An LRS\'s Agent Profile API upon processing a successful GET request without "profileId" as a parameter returns an array of ids of agent profile documents satisfying the requirements of the GET and code 200 OK (7.6, 7.6.g)', function () { var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); - return sendRequest('post', '/agents/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 204) .then(function () { delete parameters.profileId; - return sendRequest('get', '/agents/profile', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointAgentsProfile(), parameters, undefined, 200) .then(function (res) { - res.body.should.be.instanceOf(Array); - res.body.length.should.be.greaterThan(1); + var body = res.body; + expect(body).to.have.length.above(0); }) }); }); @@ -1258,14 +1283,14 @@ it('An LRS\'s returned array of ids from a successful GET request all refer to documents stored after the TimeStamp in the "since" parameter of the GET request if such a parameter was present (7.6.table4.row2, 7.6.g)', function () { var parameters = helper.buildAgentProfile(), document = helper.buildDocument(); - return sendRequest('post', '/agents/profile', parameters, document, 204) + return sendRequest('post', helper.getEndpointAgentsProfile(), parameters, document, 204) .then(function () { parameters.since = new Date(Date.now() - 1000); delete parameters.profileId; - return sendRequest('get', '/agents/profile', parameters, undefined, 200) + return sendRequest('get', helper.getEndpointAgentsProfile(), parameters, undefined, 200) .then(function (res) { - res.body.should.be.instanceOf(Array); - res.body.length.should.be.greaterThan(1); + var body = res.body; + expect(body).to.have.length.above(0); }) }); }); @@ -1277,249 +1302,402 @@ it('An LRS\'s About API upon processing a successful GET request returns a version property and code 200 OK (multiplicity, 7.7.table1.row1.c, 7.7.c)', function () { return sendRequest('get', '/about', undefined, undefined, 200) .then(function (res) { - res.body.version.should.be.instanceOf(Array); + var about = res.body; + expect(about).to.have.property('version'); }); }); it('An LRS\'s About API\'s version property is an array of strings (format, 7.7.table1.row1.a)', function () { return sendRequest('get', '/about', undefined, undefined, 200) .then(function (res) { - res.body.version.should.be.instanceOf(Array); + var about = res.body; + expect(about).to.have.property('version').to.be.an('array'); }); }); it('An LRS\'s About API\'s version property contains at least one string of "1.0.1" (7.7.d)', function () { return sendRequest('get', '/about', undefined, undefined, 200) .then(function (res) { - res.body.version.should.be.instanceOf(Array); - res.body.version.length.should.be.greaterThan(0); + var about = res.body; + expect(about).to.have.property('version').to.be.an('array'); + + var foundVersion = false + about.version.forEach(function (item) { + if (item === '1.0.1') { + foundVersion = true; + } + }) + expect(foundVersion).to.be.true; }); }); it('An LRS\'s About API\'s version property can only have values of ".9", ".95", "1.0", "1.0.0", or ""1.0." + X" with (7.7.d.a)', function () { return sendRequest('get', '/about', undefined, undefined, 200) .then(function (res) { - res.body.version.should.be.instanceOf(Array); - res.body.version.length.should.be.greaterThan(0); - var validVersions = ['.9', '.95', '1.0', '1.0.0', '1.0.1']; - res.body.version.forEach(function (item) { - validVersions.should.containEql(item); + var about = res.body; + expect(about).to.have.property('version').to.be.an('array'); + var validVersions = ['.9', '.95', '1.0', '1.0.0', '1.0.1', '1.0.2']; + about.version.forEach(function (item) { + expect(validVersions).to.include(item); }) }); }); it('An LRS\'s About API upon processing a successful GET request can return an Extension with code 200 OK (multiplicity, 7.7.table1.row2.c, 7.7.c)', function () { - return sendRequest('get', '/about', undefined, undefined, 200) + return sendRequest('get', helper.getEndpointAbout(), undefined, undefined, 200) .then(function (res) { - res.body.extensions.should.be.instanceOf(Object); + var about = res.body; + expect(about).to.have.property('extensions'); }); }); - it('Any LRS API that accepts a POST request can accept a POST request with a single query string parameter named "method" on that request (7.8.a)', function () { + it.skip('Any LRS API that accepts a POST request can accept a POST request with a single query string parameter named "method" on that request (7.8.a)', function () { var parameters = {method: 'post'}, formBody = buildFormBody(helper.buildStatement()); - return sendRequest('post', '/statements', parameters, formBody, 200); + return sendRequest('post', helper.getEndpointStatements(), parameters, formBody, 200); }); - it('A Cross Origin Request is defined as this POST request as described in the previous requirement (definition)', function (done) { + it.skip('A Cross Origin Request is defined as this POST request as described in the previous requirement (definition)', function (done) { // TODO Get clarification on this done(new Error('Implement Test')); }); - it('An LRS must parse the body of a Cross Origin Request and construct a new Request from it with the type of Request being the same as the value of the "method" parameter (7.8.a, 7.8.b)', function () { + it.skip('An LRS must parse the body of a Cross Origin Request and construct a new Request from it with the type of Request being the same as the value of the "method" parameter (7.8.a, 7.8.b)', function () { // TODO This test needs to be more through var parameters = {method: 'post'}, formBody = buildFormBody(helper.buildStatement()); - return sendRequest('post', '/statements', parameters, formBody, 200) + return sendRequest('post', helper.getEndpointStatements(), parameters, formBody, 200) .then(function (res) { parameters.method = 'get'; formBody = buildFormBody(); formBody['statementId'] = res.body[0]; - return sendRequest('post', '/statements', parameters, formBody, 200); + return sendRequest('post', helper.getEndpointStatements(), parameters, formBody, 200); }); }); - it('An LRS will map form parameters from the body of the Cross Origin Request to the similarly named HTTP Headers in the new Request (7.8.b)', function () { + it.skip('An LRS will map form parameters from the body of the Cross Origin Request to the similarly named HTTP Headers in the new Request (7.8.b)', function () { // TODO This test needs to be more through var parameters = {method: 'post'}, formBody = buildFormBody(helper.buildStatement()); - return sendRequest('post', '/statements', parameters, formBody, 200) + return sendRequest('post', helper.getEndpointStatements(), parameters, formBody, 200) .then(function (res) { parameters.method = 'get'; formBody = buildFormBody(); formBody['statementId'] = res.body[0]; - return sendRequest('post', '/statements', parameters, undefined, 200); + return sendRequest('post', helper.getEndpointStatements(), parameters, undefined, 200); }); }); - it('An LRS rejects a new Request in the same way for violating rules of this document as it would a normal Request **Implicit**', function () { + it.skip('An LRS rejects a new Request in the same way for violating rules of this document as it would a normal Request **Implicit**', function () { // TODO This test needs to be more through var parameters = {method: 'post'}, formBody = buildFormBody(delete helper.buildStatement().actor); - return sendRequest('post', '/statements', parameters, formBody, 400); + return sendRequest('post', helper.getEndpointStatements(), parameters, formBody, 400); }); - it('An LRS will reject any request sending content which does not have a form parameter with the name of "content" (7.8.c)', function () { + it.skip('An LRS will reject any request sending content which does not have a form parameter with the name of "content" (7.8.c)', function () { var parameters = {method: 'post'}, formBody = buildFormBody(helper.buildStatement()); delete formBody.content; - return sendRequest('post', '/statements', parameters, formBody, 400); + return sendRequest('post', helper.getEndpointStatements(), parameters, formBody, 400); }); - it('An LRS will treat the content of the form parameter named "content" as a UTF-8 String (7.8.c)', function () { + it.skip('An LRS will treat the content of the form parameter named "content" as a UTF-8 String (7.8.c)', function () { var parameters = {method: 'post'}, formBody = buildFormBody(helper.buildStatement()); - return sendRequest('post', '/statements', parameters, formBody, 200); + return sendRequest('post', helper.getEndpointStatements(), parameters, formBody, 200); }); - it('An LRS will reject a new Request with a form parameter named "content" if "content" is found to be binary data with error code 400 Bad Request (7.8.c)', function () { + it.skip('An LRS will reject a new Request with a form parameter named "content" if "content" is found to be binary data with error code 400 Bad Request (7.8.c)', function () { var parameters = {method: 'post'}, formBody = buildFormBody(); formBody.content = new Buffer(); - return sendRequest('post', '/statements', parameters, formBody, 400); + return sendRequest('post', helper.getEndpointStatements(), parameters, formBody, 400); }); - it('An LRS will reject a new Request which attempts to send attachment data with error code 400 Bad Request (7.8.d)', function () { + it.skip('An LRS will reject a new Request which attempts to send attachment data with error code 400 Bad Request (7.8.d)', function () { // TODO Find a consistent strategy for testing attachments var parameters = {method: 'post'}, formBody = buildFormBody(); - return sendRequest('post', '/statements', parameters, formBody, 400); + return sendRequest('post', helper.getEndpointStatements(), parameters, formBody, 400); }); - it('An LRS will reject a Cross Origin Request or new Request which contains any extra information with error code 400 Bad Request **Implicit**', function () { + it.skip('An LRS will reject a Cross Origin Request or new Request which contains any extra information with error code 400 Bad Request **Implicit**', function (done) { // TODO Find out what extra information is done(new Error('Implement Test')); }); it('An LRS accepts HEAD requests (7.10.a)', function () { - return sendRequest('head', '/statements', undefined, undefined, 200); + it('should succeed GET about with no body', function () { + return sendRequest('head', helper.getEndpointAbout(), undefined, undefined, 200); + }); + + it('should succeed GET activities with no body', function () { + var parameters = { + activityId: 'http://www.example.com/activityId/hashset' + }; + return sendRequest('head', helper.getEndpointActivities(), parameters, undefined, 200); + }); + + it('should succeed GET activities profile with no body', function () { + return sendRequest('head', helper.getEndpointActivitiesProfile(), helper.buildActivityProfile(), undefined, 200); + }); + + it('should succeed GET activities state with no body', function () { + return sendRequest('head', helper.getEndpointActivitiesState(), helper.buildState(), undefined, 200); + }); + + it('should succeed GET agents with no body', function () { + return sendRequest('head', helper.getEndpointAgents(), helper.buildAgent(), undefined, 200); + }); + + it('should succeed GET agents profile with no body', function () { + return sendRequest('head', helper.getEndpointAgentsProfile(), helper.buildAgentProfile(), undefined, 200); + }); + + it('should succeed GET statements with no body', function () { + return sendRequest('head', helper.getEndpointStatements(), undefined, undefined, 200); + }); }); - it('An LRS responds to a HEAD request in the same way as a GET request, but without the message-body (7.10.a, 7.10.a.a) **This means run ALL GET tests with HEAD**', function () { - // TODO Find a good solution for testing all combinations of this - return sendRequest('head', '/statements', undefined, undefined, 200) - .then(function (res) { - res.body.should.eql({}); - }); + describe('An LRS responds to a HEAD request in the same way as a GET request, but without the message-body (7.10.a, 7.10.a.a) **This means run ALL GET tests with HEAD**', function () { + it('should succeed GET about with no body', function () { + return sendRequest('head', helper.getEndpointAbout(), undefined, undefined, 200) + .then(function (res) { + expect(Object.keys(res.body)).to.have.length(0); + }); + }); + + it('should succeed GET activities with no body', function () { + var parameters = { + activityId: 'http://www.example.com/activityId/hashset' + }; + return sendRequest('head', helper.getEndpointActivities(), parameters, undefined, 200) + .then(function (res) { + expect(Object.keys(res.body)).to.have.length(0); + }); + }); + + it('should succeed GET activities profile with no body', function () { + return sendRequest('head', helper.getEndpointActivitiesProfile(), helper.buildActivityProfile(), undefined, 200) + .then(function (res) { + expect(Object.keys(res.body)).to.have.length(0); + }); + }); + + it('should succeed GET activities state with no body', function () { + return sendRequest('head', helper.getEndpointActivitiesState(), helper.buildState(), undefined, 200) + .then(function (res) { + expect(Object.keys(res.body)).to.have.length(0); + }); + }); + + it('should succeed GET agents with no body', function () { + return sendRequest('head', helper.getEndpointAgents(), helper.buildAgent(), undefined, 200) + .then(function (res) { + expect(Object.keys(res.body)).to.have.length(0); + }); + }); + + it('should succeed GET agents profile with no body', function () { + return sendRequest('head', helper.getEndpointAgentsProfile(), helper.buildAgentProfile(), undefined, 200) + .then(function (res) { + expect(Object.keys(res.body)).to.have.length(0); + }); + }); + + it('should succeed GET statements with no body', function () { + return sendRequest('head', helper.getEndpointStatements(), undefined, undefined, 200) + .then(function (res) { + expect(Object.keys(res.body)).to.have.length(0); + }); + }); }); - it('An LRS accepts HEAD requests without Content-Length headers (7.10.a.b)', function () { - return sendRequest('head', '/statements', undefined, undefined, 200) + it('A Person Object is an Object (7.6)', function () { + return sendRequest('get', helper.getEndpointAgents(), helper.buildAgent(), undefined, 200) .then(function (res) { - res.body.should.eql({}); + var person = res.body; + expect(person).to.be.an('object'); }); }); - it('An LRS accepts GET requests without Content-Length headers **Implicit**', function () { - return sendRequest('get', '/statements', undefined, undefined, 200) - .then(function (res) { - res.body.should.eql({}); + it('A Person Object\'s "objectType" property is a String and is "Person" (Format, Vocabulary, 7.6.table1.row1.a, 7.6.table1.row1.b)', function () { + var templates = [ + {statement: '{{statements.default}}'} + ]; + var data = createFromTemplate(templates); + var statement = data.statement; + + return sendRequest('post', helper.getEndpointStatements(), undefined, [statement], 200) + .then(function () { + return sendRequest('get', helper.getEndpointAgents(), { agent: statement.actor }, undefined, 200) + .then(function (res) { + var person = res.body; + expect(person).to.have.property('objectType').to.equal('Person'); + }); }); }); - it('A Person Object is an Object (7.6)', function () { - return sendRequest('head', '/agents', undefined, undefined, 200) - .then(function (res) { - res.body.should.be.instanceOf(Object); + it('A Person Object\'s "name" property is an Array of Strings (Multiplicity, 7.6.table1.row2.a)', function () { + var templates = [ + {statement: '{{statements.default}}'} + ]; + var data = createFromTemplate(templates); + var statement = data.statement; + + return sendRequest('post', helper.getEndpointStatements(), undefined, [statement], 200) + .then(function () { + return sendRequest('get', helper.getEndpointAgents(), { agent: statement.actor }, undefined, 200) + .then(function (res) { + var person = res.body; + expect(person).to.have.property('name').to.be.an('array'); + person.name.forEach(function(item){ + expect(item).to.be.a('string'); + }); + }); }); }); - it('A Person Object uses an "objectType" property exactly one time (Multiplicity, 7.6.table1.row1.c)', function (done) { - // JSON Parser validation - done(); - }); + it('A Person Object\'s "mbox" property is an Array of IRIs (Multiplicity, 7.6.table1.row3.a)', function () { + var templates = [ + {statement: '{{statements.default}}'} + ]; + var data = createFromTemplate(templates); + var statement = data.statement; - it('A Person Object\'s "objectType" property is a String and is "Person" (Format, Vocabulary, 7.6.table1.row1.a, 7.6.table1.row1.b)', function () { - return sendRequest('get', '/agents', undefined, undefined, 200) - .then(function (res) { - res.body.objectType.should.be.instanceOf(String); - res.body.objectType.should.equal('Person'); + return sendRequest('post', helper.getEndpointStatements(), undefined, [statement], 200) + .then(function () { + return sendRequest('get', helper.getEndpointAgents(), { agent: statement.actor }, undefined, 200) + .then(function (res) { + var person = res.body; + expect(person).to.have.property('mbox').to.be.an('array'); + person.mbox.forEach(function(item){ + expect(item).to.be.a('string'); + var email = item.substring(MAIL_TO.length); + expect(validator.isEmail(email)).to.be.true; + }); + }); }); }); - it('A Person Object uses a "name" property at most one time (Multiplicity, 7.6.table1.row2.c)', function (done) { - // JSON Parser validation - done(); - }); + it('A Person Object\'s "mbox" entries have the form "mailto:emailaddress" (Format, 7.6.table1.row3.a)', function () { + var templates = [ + {statement: '{{statements.default}}'} + ]; + var data = createFromTemplate(templates); + var statement = data.statement; - it('A Person Object\'s "name" property is an Array of Strings (Multiplicity, 7.6.table1.row2.a)', function () { - return sendRequest('get', '/agents', undefined, undefined, 200) - .then(function (res) { - res.body.name.should.be.instanceOf(Array); - res.body.name.forEach(function(item){ - item.should.be.instanceOf(String); - }); + return sendRequest('post', helper.getEndpointStatements(), undefined, [statement], 200) + .then(function () { + return sendRequest('get', helper.getEndpointAgents(), { agent: statement.actor }, undefined, 200) + .then(function (res) { + var person = res.body; + expect(person).to.have.property('mbox').to.be.an('array'); + person.mbox.forEach(function(item){ + expect(item).to.be.a('string'); + expect(item).to.match(/^mailto:/); + }); + }); }); }); - it('A Person Object uses a "mbox" property at most one time (Multiplicity, 7.6.table1.row3.c)', function (done) { - // JSON Parser validation - done(); + it('A Person Object\'s "mbox_sha1sum" property is an Array of Strings (Multiplicity, 7.6.table1.row4.a)', function () { + var templates = [ + {statement: '{{statements.default}}'} + ]; + var data = createFromTemplate(templates); + var statement = data.statement; + + return sendRequest('post', helper.getEndpointStatements(), undefined, [statement], 200) + .then(function () { + return sendRequest('get', helper.getEndpointAgents(), { agent: statement.actor }, undefined, 200) + .then(function (res) { + var person = res.body; + expect(person).to.have.property('mbox_sha1sum').to.be.an('array'); + person.mbox_sha1sum.forEach(function(item){ + expect(item).to.be.a('string'); + }); + }); + }); }); - it('A Person Object\'s "mbox" property is an Array of IRIs (Multiplicity, 7.6.table1.row3.a)', function () { - return sendRequest('get', '/agents', undefined, undefined, 200) - .then(function (res) { - res.body.mbox.should.be.instanceOf(Array); - res.body.mbox.forEach(function(item){ - validUrl.isUri(item); - }); + it('A Person Object\'s "openid" property is an Array of Strings (Multiplicity, 7.6.table1.row5.a)', function () { + var templates = [ + {statement: '{{statements.default}}'} + ]; + var data = createFromTemplate(templates); + var statement = data.statement; + + return sendRequest('post', helper.getEndpointStatements(), undefined, [statement], 200) + .then(function () { + return sendRequest('get', helper.getEndpointAgents(), { agent: statement.actor }, undefined, 200) + .then(function (res) { + var person = res.body; + expect(person).to.have.property('openid').to.be.an('array'); + person.openid.forEach(function(item){ + expect(item).to.be.a('string'); + }); + }); }); }); - it('A Person Object\'s "mbox" entries have the form "mailto:emailaddress" (Format, 7.6.table1.row3.a)', function () { - return sendRequest('get', '/agents', undefined, undefined, 200) - .then(function (res) { - res.body.mbox.should.be.instanceOf(Array); - res.body.mbox.forEach(function(item){ - item.should.containEql('mailto:'); - }); + it('A Person Object\'s "account" property is an Array of Account Objects (Multiplicity, 7.6.table1.row6.a)', function () { + var templates = [ + {statement: '{{statements.default}}'} + ]; + var data = createFromTemplate(templates); + var statement = data.statement; + + return sendRequest('post', helper.getEndpointStatements(), undefined, [statement], 200) + .then(function () { + return sendRequest('get', helper.getEndpointAgents(), { agent: statement.actor }, undefined, 200) + .then(function (res) { + var person = res.body; + expect(person).to.have.property('account').to.be.an('array'); + person.account.forEach(function(item){ + expect(item).to.be.an('object'); + }); + }); }); }); - it('A Person Object uses a "mbox_sha1sum" property at most one time (Multiplicity, 7.6.table1.row4.c)', function (done) { + it('A Person Object uses an "objectType" property exactly one time (Multiplicity, 7.6.table1.row1.c)', function (done) { // JSON Parser validation done(); }); - it('A Person Object\'s "mbox_sha1sum" property is an Array of Strings (Multiplicity, 7.6.table1.row4.a)', function () { - return sendRequest('get', '/agents', undefined, undefined, 200) - .then(function (res) { - res.body['mbox_sha1sum'].should.be.instanceOf(Array); - res.body['mbox_sha1sum'].forEach(function(item){ - item.should.be.instanceOf(String); - }); - }); + it('A Person Object uses a "name" property at most one time (Multiplicity, 7.6.table1.row2.c)', function (done) { + // JSON Parser validation + done(); }); - it('A Person Object uses an "openid" property at most one time (Multiplicity, 7.6.table1.row5.c)', function (done) { + it('A Person Object uses a "mbox" property at most one time (Multiplicity, 7.6.table1.row3.c)', function (done) { // JSON Parser validation done(); }); - it('A Person Object\'s "openid" property is an Array of Strings (Multiplicity, 7.6.table1.row5.a)', function () { - return sendRequest('get', '/agents', undefined, undefined, 200) - .then(function (res) { - res.body['openid'].should.be.instanceOf(Array); - res.body['openid'].forEach(function(item){ - item.should.be.instanceOf(String); - }); - }); + it('A Person Object uses a "mbox_sha1sum" property at most one time (Multiplicity, 7.6.table1.row4.c)', function (done) { + // JSON Parser validation + done(); }); - it('A Person Object uses an "account" property at most one time (Multiplicity, 7.6.table1.row6.c)', function (done) { + it('A Person Object uses an "openid" property at most one time (Multiplicity, 7.6.table1.row5.c)', function (done) { // JSON Parser validation done(); }); - it('A Person Object\'s "account" property is an Array of Account Objects (Multiplicity, 7.6.table1.row6.a)', function () { - return sendRequest('get', '/agents', undefined, undefined, 200) - .then(function (res) { - res.body['account'].should.be.instanceOf(Array); - res.body['account'].forEach(function(item){ - item.should.be.instanceOf(Object); // Determine easiest way to check for account object - }); - }); + it('A Person Object uses an "account" property at most one time (Multiplicity, 7.6.table1.row6.c)', function (done) { + // JSON Parser validation + done(); }); }); -}(process, require('supertest-as-promised'), require('should'), require('./../helper'), require('qs'), require('valid-url'))); + + function createFromTemplate(templates) { + // convert template mapping to JSON objects + var converted = helper.convertTemplate(templates); + // this handles if no override + var mockObject = helper.createTestObject(converted); + return mockObject; + } +}(process, require('supertest-as-promised'), require('should'), require('chai'), require('qs'), require('validator'), require('./../helper')));