diff --git a/api/namex/resources/requests.py b/api/namex/resources/requests.py index 4f96cb20d..9ce34c5d3 100644 --- a/api/namex/resources/requests.py +++ b/api/namex/resources/requests.py @@ -480,7 +480,7 @@ def patch(nr, *args, **kwargs): nrd.save_to_db() EventRecorder.record(user, Event.PATCH, nrd, json_input) - except (Exception) as err: + except Exception as err: current_app.logger.debug(err.with_traceback(None)) return jsonify(message='Internal server error'), 500 @@ -526,6 +526,15 @@ def put(nr, *args, **kwargs): if not services.name_request.valid_state_transition(user, nrd, state): return jsonify(message='you are not authorized to make these changes'), 401 + name_choice_exists = {1: False, 2: False, 3: False} + for name in json_input.get('names', None): + if name['name'] and name['name'] is not '': + name_choice_exists[name['choice']] = True + if not name_choice_exists[1]: + return jsonify(message='Data does not include a name choice 1'), 400 + if not name_choice_exists[2] and name_choice_exists[3]: + return jsonify(message='Data contains a name choice 3 without a name choice 2'), 400 + try: existing_nr = RequestDAO.get_inprogress(user) if existing_nr: diff --git a/api/tests/postman/namex-pipeline-dev.postman_collection.json b/api/tests/postman/namex-pipeline-dev.postman_collection.json index 853ab413b..a6b9d2476 100644 --- a/api/tests/postman/namex-pipeline-dev.postman_collection.json +++ b/api/tests/postman/namex-pipeline-dev.postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "bc308e4d-34bc-4a53-8bcd-0a31554c9843", + "_postman_id": "db393b63-7df8-46a7-bac1-beac126a91be", "name": "namex-pipeline-dev", "description": "# Introduction\nWhat does your API do?\n\n# Overview\nThings that the developers should know about\n\n# Authentication\nWhat is the preferred way of using the API?\n\n# Error Codes\nWhat errors and status codes can a user expect?\n\n# Rate limit\nIs there a limit to the number of requests an user can send?", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" @@ -855,6 +855,778 @@ } ] }, + { + "name": "add/delete name choices", + "item": [ + { + "name": "requests/NR # change state to inprogress", + "event": [ + { + "listen": "prerequest", + "script": { + "id": "36e019ae-a7c4-4599-8631-564ad3d11ef0", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "346c9a5d-ee8f-48cd-9b21-bad29baf9ecb", + "type": "text/javascript", + "exec": [ + "eval(globals.postmanBDD);", + "", + "tests[\"Response time is acceptable\"] = responseTime < 8000;", + "", + "it('Should be an success response', () => {", + " response.ok.should.be.true; // 2XX", + " response.error.should.be.false; // 4XX or 5XX", + " response.clientError.should.be.false; // 4XX", + " response.serverError.should.be.false; // 5XX", + " response.should.have.status(200);", + " response.statusType.should.equal(2);", + "});", + "", + "it('Should return JSON', () => {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "var jsonData = pm.response.json();", + "it('Should contain \\'message\\' confirming patch', () => {", + " response.body.should.be.an('object').with.keys(['message']);", + " jsonData.message.should.include('- patched');", + "});" + ] + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{token}}" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\"state\": \"INPROGRESS\"}" + }, + "url": { + "raw": "{{url}}/api/v1/requests/{{NR}}", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "v1", + "requests", + "{{NR}}" + ] + } + }, + "response": [] + }, + { + "name": "/requests - add name", + "event": [ + { + "listen": "test", + "script": { + "id": "63511ee5-c76d-46c6-b98d-76384b834a99", + "exec": [ + "eval(globals.postmanBDD);", + "", + "pm.test(\"Response time is less than 5000ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(5000);", + "});", + "", + "it('should return JSON', () => {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "it('should contain the un-parsed JSON text', () => {", + " response.text.should.be.a('string').with.length.above(10);", + "});", + "if (response.status == 200) {", + " it(\"Should return the required fields for an NR\", () => {", + " response.body.should.be.an('object').with.keys(['additionalInfo','applicants','comments','consentFlag','corpNum','expirationDate','furnished','hasBeenReset','id','lastUpdate','names','natureBusinessInfo','nrNum','nwpta','previousNr','previousRequestId','previousStateCd', 'priorityCd','priorityDate','requestTypeCd','state','submitCount','submittedDate','submitter_userid','userId','xproJurisdiction']);", + " });", + " ", + " it(\"Should return updated changes in the body\", () => {", + " for (var i=0; i {", + " response.body.should.be.an('object').with.keys(['errors']);", + " response.body.errors[0].should.be.an('object').with.keys(['code','message','type']);", + " response.body.errors[0].message[0].should.be.an('object').with.keys(['code','message','type']);", + " });", + " it(\"Should have the correct message for not changing NRO\", () => {", + " response.body.errors[0].message[0].type.should.include('warn');", + " response.body.errors[0].message[0].code.should.include('unable_to_update_request_changes_in_NRO');", + " });", + "}", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "id": "f8801a4b-3dcb-414e-a1f2-8f32e35abfaf", + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{token}}" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n\t\"additionalInfo\": \"More info TESTING\",\r\n\t\"applicants\": {\r\n\t\t\"addrLine1\": \"940 Blanshard Street TESTING\",\r\n\t\t\"addrLine2\": null,\r\n\t\t\"addrLine3\": null,\r\n\t\t\"city\": \"Victoria\",\r\n\t\t\"clientFirstName\": null,\r\n\t\t\"clientLastName\": null,\r\n\t\t\"contact\": \"John Test\",\r\n\t\t\"countryTypeCd\": \"CA\",\r\n\t\t\"declineNotificationInd\": null,\r\n\t\t\"emailAddress\": \"testoutputs@gov.bc.ca\",\r\n\t\t\"faxNumber\": null,\r\n\t\t\"firstName\": \"John\",\r\n\t\t\"lastName\": \"Test\",\r\n\t\t\"middleName\": null,\r\n\t\t\"partyId\": 1486844,\r\n\t\t\"phoneNumber\": \"2505555555\",\r\n\t\t\"postalCd\": \"V8V4K8\",\r\n\t\t\"stateProvinceCd\": \"BC\"\r\n\t},\r\n\t\"comments\": [\r\n\t\t{\r\n\t\t\t\"comment\": \"This is a new comment\"\r\n\t\t}\r\n\t],\r\n\t\"consentFlag\": null,\r\n\t\"corpNum\": null,\r\n\t\"expirationDate\": null,\r\n\t\"furnished\": \"N\",\r\n\t\"lastUpdate\": \"Tue, 04 Dec 2018 14:45:19 GMT\",\r\n\t\"names\": [{\r\n\t\t\"choice\": 1,\r\n\t\t\"comment\": null,\r\n\t\t\"conflict1\": \"\",\r\n\t\t\"conflict1_num\": \"\",\r\n\t\t\"conflict2\": \"\",\r\n\t\t\"conflict2_num\": \"\",\r\n\t\t\"conflict3\": \"\",\r\n\t\t\"conflict3_num\": \"\",\r\n\t\t\"consumptionDate\": null,\r\n\t\t\"decision_text\": \"\",\r\n\t\t\"name\": \"A C C DIAMONDS LTD. LIMITED TESTING\",\r\n\t\t\"state\": \"NE\"\r\n\t},\r\n\t{\r\n\t\t\"choice\": 2,\r\n\t\t\"comment\": null,\r\n\t\t\"conflict1\": \"\",\r\n\t\t\"conflict1_num\": \"\",\r\n\t\t\"conflict2\": \"\",\r\n\t\t\"conflict2_num\": \"\",\r\n\t\t\"conflict3\": \"\",\r\n\t\t\"conflict3_num\": \"\",\r\n\t\t\"consumptionDate\": null,\r\n\t\t\"decision_text\": \"\",\r\n\t\t\"name\": \"TEST NAME CHOICE 2 ADD\",\r\n\t\t\"state\": \"NE\"\r\n\t},\r\n\t{\r\n\t\t\"choice\": 3,\r\n\t\t\"comment\": null,\r\n\t\t\"conflict1\": \"\",\r\n\t\t\"conflict1_num\": \"\",\r\n\t\t\"conflict2\": \"\",\r\n\t\t\"conflict2_num\": \"\",\r\n\t\t\"conflict3\": \"\",\r\n\t\t\"conflict3_num\": \"\",\r\n\t\t\"consumptionDate\": null,\r\n\t\t\"decision_text\": \"\",\r\n\t\t\"name\": \"TEST NAME CHOICE 3 ADD\",\r\n\t\t\"state\": \"NE\"\r\n\t}],\r\n\t\"natureBusinessInfo\": \"Nature of business can be pretty long so this one is more realistic. It even contains spaces and punctuation.\",\r\n\t\"nrNum\": \"NR 3597836\",\r\n\t\"nwpta\": [],\r\n\t\"previousNr\": null,\r\n\t\"previousRequestId\": null,\r\n\t\"priorityCd\": \"Y\",\r\n\t\"priorityDate\": \"Fri, 07 Dec 2018 11:26:51 GMT\",\r\n\t\"requestTypeCd\": \"CR\",\r\n\t\"state\": \"INPROGRESS\",\r\n\t\"submitCount\": 1,\r\n\t\"submittedDate\": \"Thu, 15 Nov 2018 08:59:18 GMT\",\r\n\t\"submitter_userid\": \"\",\r\n\t\"userId\": \"postman\",\r\n\t\"xproJurisdiction\": null\r\n}" + }, + "url": { + "raw": "{{url}}/api/v1/requests/{{NR}}", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "v1", + "requests", + "{{NR}}" + ] + } + }, + "response": [] + }, + { + "name": "requests/NR - check name add", + "event": [ + { + "listen": "test", + "script": { + "id": "c1429a8d-6bf6-485e-a78f-3401419da30d", + "exec": [ + "eval(globals.postmanBDD);", + "", + "pm.test(\"Response time is less than 5000ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(5000);", + "});", + "", + "it('should be an success response', () => {", + " response.ok.should.be.true; // 2XX", + " response.error.should.be.false; // 4XX or 5XX", + " response.clientError.should.be.false; // 4XX", + " response.serverError.should.be.false; // 5XX", + " response.should.have.status(200);", + " response.statusType.should.equal(2);", + "});", + "", + "it('should return JSON', () => {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "it('should contain the un-parsed JSON text', () => {", + " response.text.should.be.a('string').with.length.above(10);", + "});", + "", + "it(\"Should return the required fields for an NR\", () => {", + " response.body.should.be.an('object').with.keys(['additionalInfo','applicants','comments','consentFlag','corpNum', 'expirationDate','furnished','hasBeenReset','id','lastUpdate','names','natureBusinessInfo','nrNum','nwpta','previousNr', 'previousRequestId','previousStateCd', 'priorityCd','priorityDate','requestTypeCd','state','submitCount','submittedDate','submitter_userid','userId', 'xproJurisdiction']);", + "});", + "", + "for (var i=0; i {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "it('should contain the un-parsed JSON text', () => {", + " response.text.should.be.a('string').with.length.above(10);", + "});", + "", + "if (response.status == 200) {", + " it(\"Should return the required fields for an NR\", () => {", + " response.body.should.be.an('object').with.keys(['additionalInfo','applicants','comments','consentFlag','corpNum','expirationDate','furnished','hasBeenReset','id','lastUpdate','names','natureBusinessInfo','nrNum','nwpta','previousNr','previousRequestId','previousStateCd', 'priorityCd','priorityDate','requestTypeCd','state','submitCount','submittedDate','submitter_userid','userId','xproJurisdiction']);", + " });", + " ", + " for (var i=0; i {", + " response.body.should.be.an('object').with.keys(['errors']);", + " response.body.errors[0].should.be.an('object').with.keys(['code','message','type']);", + " response.body.errors[0].message[0].should.be.an('object').with.keys(['code','message','type']);", + " });", + " it(\"Should have the correct message for not changing NRO\", () => {", + " response.body.errors[0].message[0].type.should.include('warn');", + " response.body.errors[0].message[0].code.should.include('unable_to_update_request_changes_in_NRO');", + " });", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "content-type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{token}}" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n\t\"additionalInfo\": \"More info\",\r\n\t\"applicants\": {\r\n\t\t\"addrLine1\": \"940 Blanshard Street\",\r\n\t\t\"addrLine2\": null,\r\n\t\t\"addrLine3\": null,\r\n\t\t\"city\": \"Victoria\",\r\n\t\t\"clientFirstName\": null,\r\n\t\t\"clientLastName\": null,\r\n\t\t\"contact\": \"John Test\",\r\n\t\t\"countryTypeCd\": \"CA\",\r\n\t\t\"declineNotificationInd\": null,\r\n\t\t\"emailAddress\": \"testoutputs@gov.bc.ca\",\r\n\t\t\"faxNumber\": null,\r\n\t\t\"firstName\": \"John\",\r\n\t\t\"lastName\": \"Test\",\r\n\t\t\"middleName\": null,\r\n\t\t\"partyId\": 1486844,\r\n\t\t\"phoneNumber\": \"2505555555\",\r\n\t\t\"postalCd\": \"V8V4K8\",\r\n\t\t\"stateProvinceCd\": \"BC\"\r\n\t},\r\n\t\"comments\": [],\r\n\t\"consentFlag\": null,\r\n\t\"corpNum\": null,\r\n\t\"expirationDate\": null,\r\n\t\"furnished\": \"N\",\r\n\t\"hasBeenReset\": false,\r\n\t\"lastUpdate\": \"Tue, 04 Dec 2018 14:45:19 GMT\",\r\n\t\"names\": [{\r\n\t\t\"choice\": 1,\r\n\t\t\"comment\": null,\r\n\t\t\"conflict1\": \"\",\r\n\t\t\"conflict1_num\": \"\",\r\n\t\t\"conflict2\": \"\",\r\n\t\t\"conflict2_num\": \"\",\r\n\t\t\"conflict3\": \"\",\r\n\t\t\"conflict3_num\": \"\",\r\n\t\t\"consumptionDate\": null,\r\n\t\t\"decision_text\": \"\",\r\n\t\t\"name\": \"A C C DIAMONDS LTD. LIMITED\",\r\n\t\t\"state\": \"NE\"\r\n\t},\r\n\t{\r\n\t\t\"choice\": 2,\r\n\t\t\"comment\": null,\r\n\t\t\"conflict1\": \"\",\r\n\t\t\"conflict1_num\": \"\",\r\n\t\t\"conflict2\": \"\",\r\n\t\t\"conflict2_num\": \"\",\r\n\t\t\"conflict3\": \"\",\r\n\t\t\"conflict3_num\": \"\",\r\n\t\t\"consumptionDate\": null,\r\n\t\t\"decision_text\": \"\",\r\n\t\t\"name\": \"\",\r\n\t\t\"state\": \"NE\"\r\n\t},\r\n\t{\r\n\t\t\"choice\": 3,\r\n\t\t\"comment\": null,\r\n\t\t\"conflict1\": \"\",\r\n\t\t\"conflict1_num\": \"\",\r\n\t\t\"conflict2\": \"\",\r\n\t\t\"conflict2_num\": \"\",\r\n\t\t\"conflict3\": \"\",\r\n\t\t\"conflict3_num\": \"\",\r\n\t\t\"consumptionDate\": null,\r\n\t\t\"decision_text\": \"\",\r\n\t\t\"name\": \"\",\r\n\t\t\"state\": \"NE\"\r\n\t}],\r\n\t\"natureBusinessInfo\": \"Nature of business can be pretty long so this one is more realistic. It even contains spaces and punctuation.\",\r\n\t\"nrNum\": \"NR 3597836\",\r\n\t\"nwpta\": [],\r\n\t\"previousNr\": null,\r\n\t\"previousRequestId\": null,\r\n\t\"priorityCd\": \"Y\",\r\n\t\"priorityDate\": \"Fri, 07 Dec 2018 11:26:51 GMT\",\r\n\t\"requestTypeCd\": \"CR\",\r\n\t\"state\": \"INPROGRESS\",\r\n\t\"submitCount\": 1,\r\n\t\"submittedDate\": \"Thu, 15 Nov 2018 08:59:18 GMT\",\r\n\t\"submitter_userid\": \"\",\r\n\t\"userId\": \"postman\",\r\n\t\"xproJurisdiction\": null\r\n}" + }, + "url": { + "raw": "{{url}}/api/v1/requests/{{NR}}", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "v1", + "requests", + "{{NR}}" + ] + } + }, + "response": [] + }, + { + "name": "requests/NR - check values reset", + "event": [ + { + "listen": "test", + "script": { + "id": "c1429a8d-6bf6-485e-a78f-3401419da30d", + "exec": [ + "eval(globals.postmanBDD);", + "", + "pm.test(\"Response time is less than 5000ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(5000);", + "});", + "", + "it('should be an success response', () => {", + " response.ok.should.be.true; // 2XX", + " response.error.should.be.false; // 4XX or 5XX", + " response.clientError.should.be.false; // 4XX", + " response.serverError.should.be.false; // 5XX", + " response.should.have.status(200);", + " response.statusType.should.equal(2);", + "});", + "", + "it('should return JSON', () => {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "it('should contain the un-parsed JSON text', () => {", + " response.text.should.be.a('string').with.length.above(10);", + "});", + "", + "it(\"Should return the required fields for an NR\", () => {", + " response.body.should.be.an('object').with.keys(['additionalInfo','applicants','comments','consentFlag','corpNum', 'expirationDate','furnished','hasBeenReset','id','lastUpdate','names','natureBusinessInfo','nrNum','nwpta','previousNr', 'previousRequestId','previousStateCd', 'priorityCd','priorityDate','requestTypeCd','state','submitCount','submittedDate','submitter_userid','userId', 'xproJurisdiction']);", + "});", + "", + "for (var i=0; i {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "it('should be an unsuccessful response', () => {", + " response.ok.should.be.false; // 2XX", + " response.error.should.be.true; // 4XX or 5XX", + " response.clientError.should.be.true; // 4XX", + " response.serverError.should.be.false; // 5XX", + " response.statusType.should.equal(4);", + " response.should.have.status(400);", + "});", + "", + "it('should contain the un-parsed JSON text', () => {", + " response.text.should.be.a('string').with.length.above(10);", + "});", + "", + "it(\"Should return an error message\", () => {", + " response.body.should.be.an('object').with.keys(['message']);", + " response.body.message.should.include('Data does not include a name choice 1');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "id": "f8801a4b-3dcb-414e-a1f2-8f32e35abfaf", + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{token}}" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n\t\"additionalInfo\": \"More info TESTING\",\r\n\t\"applicants\": {\r\n\t\t\"addrLine1\": \"940 Blanshard Street TESTING\",\r\n\t\t\"addrLine2\": null,\r\n\t\t\"addrLine3\": null,\r\n\t\t\"city\": \"Victoria\",\r\n\t\t\"clientFirstName\": null,\r\n\t\t\"clientLastName\": null,\r\n\t\t\"contact\": \"John Test\",\r\n\t\t\"countryTypeCd\": \"CA\",\r\n\t\t\"declineNotificationInd\": null,\r\n\t\t\"emailAddress\": \"testoutputs@gov.bc.ca\",\r\n\t\t\"faxNumber\": null,\r\n\t\t\"firstName\": \"John\",\r\n\t\t\"lastName\": \"Test\",\r\n\t\t\"middleName\": null,\r\n\t\t\"partyId\": 1486844,\r\n\t\t\"phoneNumber\": \"2505555555\",\r\n\t\t\"postalCd\": \"V8V4K8\",\r\n\t\t\"stateProvinceCd\": \"BC\"\r\n\t},\r\n\t\"comments\": [\r\n\t\t{\r\n\t\t\t\"comment\": \"This is a new comment\"\r\n\t\t}\r\n\t],\r\n\t\"consentFlag\": null,\r\n\t\"corpNum\": null,\r\n\t\"expirationDate\": null,\r\n\t\"furnished\": \"N\",\r\n\t\"lastUpdate\": \"Tue, 04 Dec 2018 14:45:19 GMT\",\r\n\t\"names\": [{\r\n\t\t\"choice\": 1,\r\n\t\t\"comment\": null,\r\n\t\t\"conflict1\": \"\",\r\n\t\t\"conflict1_num\": \"\",\r\n\t\t\"conflict2\": \"\",\r\n\t\t\"conflict2_num\": \"\",\r\n\t\t\"conflict3\": \"\",\r\n\t\t\"conflict3_num\": \"\",\r\n\t\t\"consumptionDate\": null,\r\n\t\t\"decision_text\": \"\",\r\n\t\t\"name\": \"\",\r\n\t\t\"state\": \"NE\"\r\n\t},\r\n\t{\r\n\t\t\"choice\": 2,\r\n\t\t\"comment\": null,\r\n\t\t\"conflict1\": \"\",\r\n\t\t\"conflict1_num\": \"\",\r\n\t\t\"conflict2\": \"\",\r\n\t\t\"conflict2_num\": \"\",\r\n\t\t\"conflict3\": \"\",\r\n\t\t\"conflict3_num\": \"\",\r\n\t\t\"consumptionDate\": null,\r\n\t\t\"decision_text\": \"\",\r\n\t\t\"name\": \"Should not get added\",\r\n\t\t\"state\": \"NE\"\r\n\t},\r\n\t{\r\n\t\t\"choice\": 3,\r\n\t\t\"comment\": null,\r\n\t\t\"conflict1\": \"\",\r\n\t\t\"conflict1_num\": \"\",\r\n\t\t\"conflict2\": \"\",\r\n\t\t\"conflict2_num\": \"\",\r\n\t\t\"conflict3\": \"\",\r\n\t\t\"conflict3_num\": \"\",\r\n\t\t\"consumptionDate\": null,\r\n\t\t\"decision_text\": \"\",\r\n\t\t\"name\": \"Should not get added\",\r\n\t\t\"state\": \"NE\"\r\n\t}],\r\n\t\"natureBusinessInfo\": \"Nature of business can be pretty long so this one is more realistic. It even contains spaces and punctuation.\",\r\n\t\"nrNum\": \"NR 3597836\",\r\n\t\"nwpta\": [],\r\n\t\"previousNr\": null,\r\n\t\"previousRequestId\": null,\r\n\t\"priorityCd\": \"Y\",\r\n\t\"priorityDate\": \"Fri, 07 Dec 2018 11:26:51 GMT\",\r\n\t\"requestTypeCd\": \"CR\",\r\n\t\"state\": \"INPROGRESS\",\r\n\t\"submitCount\": 1,\r\n\t\"submittedDate\": \"Thu, 15 Nov 2018 08:59:18 GMT\",\r\n\t\"submitter_userid\": \"\",\r\n\t\"userId\": \"postman\",\r\n\t\"xproJurisdiction\": null\r\n}" + }, + "url": { + "raw": "{{url}}/api/v1/requests/{{NR}}", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "v1", + "requests", + "{{NR}}" + ] + } + }, + "response": [] + }, + { + "name": "/requests - try adding name3 without name2", + "event": [ + { + "listen": "test", + "script": { + "id": "63511ee5-c76d-46c6-b98d-76384b834a99", + "exec": [ + "eval(globals.postmanBDD);", + "", + "pm.test(\"Response time is less than 5000ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(5000);", + "});", + "", + "it('should return JSON', () => {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "it('should be an unsuccessful response', () => {", + " response.ok.should.be.false; // 2XX", + " response.error.should.be.true; // 4XX or 5XX", + " response.clientError.should.be.true; // 4XX", + " response.serverError.should.be.false; // 5XX", + " response.statusType.should.equal(4);", + " response.should.have.status(400);", + "});", + "", + "it('should contain the un-parsed JSON text', () => {", + " response.text.should.be.a('string').with.length.above(10);", + "});", + "", + "it(\"Should return an error message\", () => {", + " response.body.should.be.an('object').with.keys(['message']);", + " response.body.message.should.include('Data contains a name choice 3 without a name choice 2');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "id": "f8801a4b-3dcb-414e-a1f2-8f32e35abfaf", + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{token}}" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n\t\"additionalInfo\": \"More info TESTING\",\r\n\t\"applicants\": {\r\n\t\t\"addrLine1\": \"940 Blanshard Street TESTING\",\r\n\t\t\"addrLine2\": null,\r\n\t\t\"addrLine3\": null,\r\n\t\t\"city\": \"Victoria\",\r\n\t\t\"clientFirstName\": null,\r\n\t\t\"clientLastName\": null,\r\n\t\t\"contact\": \"John Test\",\r\n\t\t\"countryTypeCd\": \"CA\",\r\n\t\t\"declineNotificationInd\": null,\r\n\t\t\"emailAddress\": \"testoutputs@gov.bc.ca\",\r\n\t\t\"faxNumber\": null,\r\n\t\t\"firstName\": \"John\",\r\n\t\t\"lastName\": \"Test\",\r\n\t\t\"middleName\": null,\r\n\t\t\"partyId\": 1486844,\r\n\t\t\"phoneNumber\": \"2505555555\",\r\n\t\t\"postalCd\": \"V8V4K8\",\r\n\t\t\"stateProvinceCd\": \"BC\"\r\n\t},\r\n\t\"comments\": [\r\n\t\t{\r\n\t\t\t\"comment\": \"This is a new comment\"\r\n\t\t}\r\n\t],\r\n\t\"consentFlag\": null,\r\n\t\"corpNum\": null,\r\n\t\"expirationDate\": null,\r\n\t\"furnished\": \"N\",\r\n\t\"lastUpdate\": \"Tue, 04 Dec 2018 14:45:19 GMT\",\r\n\t\"names\": [{\r\n\t\t\"choice\": 1,\r\n\t\t\"comment\": null,\r\n\t\t\"conflict1\": \"\",\r\n\t\t\"conflict1_num\": \"\",\r\n\t\t\"conflict2\": \"\",\r\n\t\t\"conflict2_num\": \"\",\r\n\t\t\"conflict3\": \"\",\r\n\t\t\"conflict3_num\": \"\",\r\n\t\t\"consumptionDate\": null,\r\n\t\t\"decision_text\": \"\",\r\n\t\t\"name\": \"A C C DIAMONDS LTD. LIMITED\",\r\n\t\t\"state\": \"NE\"\r\n\t},\r\n\t{\r\n\t\t\"choice\": 2,\r\n\t\t\"comment\": null,\r\n\t\t\"conflict1\": \"\",\r\n\t\t\"conflict1_num\": \"\",\r\n\t\t\"conflict2\": \"\",\r\n\t\t\"conflict2_num\": \"\",\r\n\t\t\"conflict3\": \"\",\r\n\t\t\"conflict3_num\": \"\",\r\n\t\t\"consumptionDate\": null,\r\n\t\t\"decision_text\": \"\",\r\n\t\t\"name\": \"\",\r\n\t\t\"state\": \"NE\"\r\n\t},\r\n\t{\r\n\t\t\"choice\": 3,\r\n\t\t\"comment\": null,\r\n\t\t\"conflict1\": \"\",\r\n\t\t\"conflict1_num\": \"\",\r\n\t\t\"conflict2\": \"\",\r\n\t\t\"conflict2_num\": \"\",\r\n\t\t\"conflict3\": \"\",\r\n\t\t\"conflict3_num\": \"\",\r\n\t\t\"consumptionDate\": null,\r\n\t\t\"decision_text\": \"\",\r\n\t\t\"name\": \"TEST NAME CHOICE 3 ADD\",\r\n\t\t\"state\": \"NE\"\r\n\t}],\r\n\t\"natureBusinessInfo\": \"Nature of business can be pretty long so this one is more realistic. It even contains spaces and punctuation.\",\r\n\t\"nrNum\": \"NR 3597836\",\r\n\t\"nwpta\": [],\r\n\t\"previousNr\": null,\r\n\t\"previousRequestId\": null,\r\n\t\"priorityCd\": \"Y\",\r\n\t\"priorityDate\": \"Fri, 07 Dec 2018 11:26:51 GMT\",\r\n\t\"requestTypeCd\": \"CR\",\r\n\t\"state\": \"INPROGRESS\",\r\n\t\"submitCount\": 1,\r\n\t\"submittedDate\": \"Thu, 15 Nov 2018 08:59:18 GMT\",\r\n\t\"submitter_userid\": \"\",\r\n\t\"userId\": \"postman\",\r\n\t\"xproJurisdiction\": null\r\n}" + }, + "url": { + "raw": "{{url}}/api/v1/requests/{{NR}}", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "v1", + "requests", + "{{NR}}" + ] + } + }, + "response": [] + }, + { + "name": "requests/NR - check no values were changed", + "event": [ + { + "listen": "test", + "script": { + "id": "c1429a8d-6bf6-485e-a78f-3401419da30d", + "exec": [ + "eval(globals.postmanBDD);", + "", + "pm.test(\"Response time is less than 5000ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(5000);", + "});", + "", + "it('should be an success response', () => {", + " response.ok.should.be.true; // 2XX", + " response.error.should.be.false; // 4XX or 5XX", + " response.clientError.should.be.false; // 4XX", + " response.serverError.should.be.false; // 5XX", + " response.should.have.status(200);", + " response.statusType.should.equal(2);", + "});", + "", + "it('should return JSON', () => {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "it('should contain the un-parsed JSON text', () => {", + " response.text.should.be.a('string').with.length.above(10);", + "});", + "", + "it(\"Should return the required fields for an NR\", () => {", + " response.body.should.be.an('object').with.keys(['additionalInfo','applicants','comments','consentFlag','corpNum', 'expirationDate','furnished','hasBeenReset','id','lastUpdate','names','natureBusinessInfo','nrNum','nwpta','previousNr', 'previousRequestId','previousStateCd', 'priorityCd','priorityDate','requestTypeCd','state','submitCount','submittedDate','submitter_userid','userId', 'xproJurisdiction']);", + "});", + "", + "for (var i=0; i {", + " response.ok.should.be.true; // 2XX", + " response.error.should.be.false; // 4XX or 5XX", + " response.clientError.should.be.false; // 4XX", + " response.serverError.should.be.false; // 5XX", + " response.should.have.status(200);", + " response.statusType.should.equal(2);", + "});", + "", + "it('Should return JSON', () => {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "var jsonData = pm.response.json();", + "it('Should contain \\'message\\' confirming patch', () => {", + " response.body.should.be.an('object').with.keys(['message']);", + " jsonData.message.should.include('- patched');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{token}}" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\"state\": \"HOLD\"}" + }, + "url": { + "raw": "{{url}}/api/v1/requests/{{NR}}", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "v1", + "requests", + "{{NR}}" + ] + } + }, + "response": [] + } + ] + }, { "name": "requests+names", "item": [ @@ -1015,7 +1787,6 @@ " response.error.should.be.false; // 4XX or 5XX", " response.clientError.should.be.false; // 4XX", " response.serverError.should.be.false; // 5XX", - " response.should.have.status(200);", " response.statusType.should.equal(2);", "});", "", @@ -1027,12 +1798,14 @@ "", "var jsonData = pm.response.json();", "it('Should contain \\'message\\' confirming patch', () => {", - " response.body.should.be.an('object').with.keys(['message']);", + " if (response.status == 200)", + " response.body.should.be.an('object').with.keys(['message']);", + " else", + " response.body.should.be.an('object').with.keys(['message', 'warnings']);", " jsonData.message.should.include('- patched');", "});", "", "pm.environment.unset(\"queued_nr\"); ", - "", "" ], "type": "text/javascript" diff --git a/api/tests/postman/namex-pipeline-test.postman_collection.json b/api/tests/postman/namex-pipeline-test.postman_collection.json index d2ed158bf..9c56672ca 100644 --- a/api/tests/postman/namex-pipeline-test.postman_collection.json +++ b/api/tests/postman/namex-pipeline-test.postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "b864d9f1-c26e-4fe0-8b04-a73629fae8a8", + "_postman_id": "c7d80c36-e84c-480c-b1bf-e622e01f88be", "name": "namex-pipeline-test", "description": "# Introduction\nWhat does your API do?\n\n# Overview\nThings that the developers should know about\n\n# Authentication\nWhat is the preferred way of using the API?\n\n# Error Codes\nWhat errors and status codes can a user expect?\n\n# Rate limit\nIs there a limit to the number of requests an user can send?", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" @@ -855,6 +855,778 @@ } ] }, + { + "name": "add/delete name choices", + "item": [ + { + "name": "requests/NR # change state to inprogress", + "event": [ + { + "listen": "prerequest", + "script": { + "id": "36e019ae-a7c4-4599-8631-564ad3d11ef0", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "346c9a5d-ee8f-48cd-9b21-bad29baf9ecb", + "type": "text/javascript", + "exec": [ + "eval(globals.postmanBDD);", + "", + "tests[\"Response time is acceptable\"] = responseTime < 8000;", + "", + "it('Should be an success response', () => {", + " response.ok.should.be.true; // 2XX", + " response.error.should.be.false; // 4XX or 5XX", + " response.clientError.should.be.false; // 4XX", + " response.serverError.should.be.false; // 5XX", + " response.should.have.status(200);", + " response.statusType.should.equal(2);", + "});", + "", + "it('Should return JSON', () => {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "var jsonData = pm.response.json();", + "it('Should contain \\'message\\' confirming patch', () => {", + " response.body.should.be.an('object').with.keys(['message']);", + " jsonData.message.should.include('- patched');", + "});" + ] + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{token}}" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\"state\": \"INPROGRESS\"}" + }, + "url": { + "raw": "{{url}}/api/v1/requests/{{NR}}", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "v1", + "requests", + "{{NR}}" + ] + } + }, + "response": [] + }, + { + "name": "/requests - add name", + "event": [ + { + "listen": "test", + "script": { + "id": "63511ee5-c76d-46c6-b98d-76384b834a99", + "exec": [ + "eval(globals.postmanBDD);", + "", + "pm.test(\"Response time is less than 5000ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(5000);", + "});", + "", + "it('should return JSON', () => {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "it('should contain the un-parsed JSON text', () => {", + " response.text.should.be.a('string').with.length.above(10);", + "});", + "if (response.status == 200) {", + " it(\"Should return the required fields for an NR\", () => {", + " response.body.should.be.an('object').with.keys(['additionalInfo','applicants','comments','consentFlag','corpNum','expirationDate','furnished','hasBeenReset','id','lastUpdate','names','natureBusinessInfo','nrNum','nwpta','previousNr','previousRequestId','previousStateCd', 'priorityCd','priorityDate','requestTypeCd','state','submitCount','submittedDate','submitter_userid','userId','xproJurisdiction']);", + " });", + " ", + " it(\"Should return updated changes in the body\", () => {", + " for (var i=0; i {", + " response.body.should.be.an('object').with.keys(['errors']);", + " response.body.errors[0].should.be.an('object').with.keys(['code','message','type']);", + " response.body.errors[0].message[0].should.be.an('object').with.keys(['code','message','type']);", + " });", + " it(\"Should have the correct message for not changing NRO\", () => {", + " response.body.errors[0].message[0].type.should.include('warn');", + " response.body.errors[0].message[0].code.should.include('unable_to_update_request_changes_in_NRO');", + " });", + "}", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "id": "f8801a4b-3dcb-414e-a1f2-8f32e35abfaf", + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{token}}" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"additionalInfo\": \"This is additional info entered by the applicant.\",\n \"applicants\": {\n \"addrLine1\": \"zzz1571 ABBOTT ST\",\n \"addrLine2\": null,\n \"addrLine3\": null,\n \"city\": \"zzzVictoria\",\n \"clientFirstName\": \"qqqGerald\",\n \"clientLastName\": \"qqqSmith\",\n \"contact\": \"zzzJeffrey Hall\",\n \"countryTypeCd\": \"CA\",\n \"declineNotificationInd\": \"N\",\n \"emailAddress\": \"lorna.trent@gov.bc.ca\",\n \"faxNumber\": \"250-638-9694\",\n \"firstName\": \"zzzLorna\",\n \"lastName\": \"zzzTrent\",\n \"middleName\": null,\n \"partyId\": 1051,\n \"phoneNumber\": \"250-635-7342\",\n \"postalCd\": \"V9E 4S3\",\n \"stateProvinceCd\": \"BC\"\n },\n \"comments\": [],\n \"consentFlag\": null,\n \"corpNum\": null,\n \"expirationDate\": null,\n \"furnished\": \"N\",\n \"hasBeenReset\": false,\n \"id\": 1051,\n \"lastUpdate\": \"Thu, 20 Sep 2018 23:02:17 GMT\",\n \"names\": [\n {\n \"choice\": 1,\n \"comment\": null,\n \"conflict1\": null,\n \"conflict1_num\": null,\n \"conflict2\": null,\n \"conflict2_num\": null,\n \"conflict3\": null,\n \"conflict3_num\": null,\n \"consumptionDate\": null,\n \"decision_text\": null,\n \"name\": \"STRANGWAY & SONS ACCOUNTING SERVICES TESTING\",\n \"state\": \"NE\"\n },\n\t\t{\n\t\t\t\"choice\": 2,\n\t\t\t\"comment\": null,\n\t\t\t\"conflict1\": \"\",\n\t\t\t\"conflict1_num\": \"\",\n\t\t\t\"conflict2\": \"\",\n\t\t\t\"conflict2_num\": \"\",\n\t\t\t\"conflict3\": \"\",\n\t\t\t\"conflict3_num\": \"\",\n\t\t\t\"consumptionDate\": null,\n\t\t\t\"decision_text\": \"\",\n\t\t\t\"name\": \"TEST NAME CHOICE 2 ADD\",\n\t\t\t\"state\": \"NE\"\n\t\t},\n\t\t{\n\t\t\t\"choice\": 3,\n\t\t\t\"comment\": null,\n\t\t\t\"conflict1\": \"\",\n\t\t\t\"conflict1_num\": \"\",\n\t\t\t\"conflict2\": \"\",\n\t\t\t\"conflict2_num\": \"\",\n\t\t\t\"conflict3\": \"\",\n\t\t\t\"conflict3_num\": \"\",\n\t\t\t\"consumptionDate\": null,\n\t\t\t\"decision_text\": \"\",\n\t\t\t\"name\": \"TEST NAME CHOICE 3 ADD\",\n\t\t\t\"state\": \"NE\"\n\t\t}\n\t],\n \"natureBusinessInfo\": \"Corporate Accounting Firm\",\n \"nrNum\": \"NR 2943527\",\n \"nwpta\": [],\n \"previousNr\": null,\n \"priorityCd\": \"Y\",\n\t\"priorityDate\": \"Fri, 07 Dec 2018 11:26:51 GMT\",\n \"requestTypeCd\": \"XCR\",\n \"state\": \"INPROGRESS\",\n \"submitCount\": 1,\n \"submittedDate\": \"Thu, 20 Sep 2018 10:27:55 GMT\",\n \"submitter_userid\": \"\",\n \"userId\": \"postman\",\n \"xproJurisdiction\": \"NEW BRUNSWICK\"\n}" + }, + "url": { + "raw": "{{url}}/api/v1/requests/{{NR}}", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "v1", + "requests", + "{{NR}}" + ] + } + }, + "response": [] + }, + { + "name": "requests/NR - check name add", + "event": [ + { + "listen": "test", + "script": { + "id": "c1429a8d-6bf6-485e-a78f-3401419da30d", + "exec": [ + "eval(globals.postmanBDD);", + "", + "pm.test(\"Response time is less than 5000ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(5000);", + "});", + "", + "it('should be an success response', () => {", + " response.ok.should.be.true; // 2XX", + " response.error.should.be.false; // 4XX or 5XX", + " response.clientError.should.be.false; // 4XX", + " response.serverError.should.be.false; // 5XX", + " response.should.have.status(200);", + " response.statusType.should.equal(2);", + "});", + "", + "it('should return JSON', () => {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "it('should contain the un-parsed JSON text', () => {", + " response.text.should.be.a('string').with.length.above(10);", + "});", + "", + "it(\"Should return the required fields for an NR\", () => {", + " response.body.should.be.an('object').with.keys(['additionalInfo','applicants','comments','consentFlag','corpNum', 'expirationDate','furnished','hasBeenReset','id','lastUpdate','names','natureBusinessInfo','nrNum','nwpta','previousNr', 'previousRequestId','previousStateCd', 'priorityCd','priorityDate','requestTypeCd','state','submitCount','submittedDate','submitter_userid','userId', 'xproJurisdiction']);", + "});", + "", + "for (var i=0; i {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "it('should contain the un-parsed JSON text', () => {", + " response.text.should.be.a('string').with.length.above(10);", + "});", + "", + "if (response.status == 200) {", + " it(\"Should return the required fields for an NR\", () => {", + " response.body.should.be.an('object').with.keys(['additionalInfo','applicants','comments','consentFlag','corpNum','expirationDate','furnished','hasBeenReset','id','lastUpdate','names','natureBusinessInfo','nrNum','nwpta','previousNr','previousRequestId','previousStateCd', 'priorityCd','priorityDate','requestTypeCd','state','submitCount','submittedDate','submitter_userid','userId','xproJurisdiction']);", + " });", + " ", + " for (var i=0; i {", + " response.body.should.be.an('object').with.keys(['errors']);", + " response.body.errors[0].should.be.an('object').with.keys(['code','message','type']);", + " response.body.errors[0].message[0].should.be.an('object').with.keys(['code','message','type']);", + " });", + " it(\"Should have the correct message for not changing NRO\", () => {", + " response.body.errors[0].message[0].type.should.include('warn');", + " response.body.errors[0].message[0].code.should.include('unable_to_update_request_changes_in_NRO');", + " });", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "content-type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{token}}" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"additionalInfo\": \"This is additional info entered by the applicant.\",\n \"applicants\": {\n \"addrLine1\": \"zzz1571 ABBOTT ST\",\n \"addrLine2\": null,\n \"addrLine3\": null,\n \"city\": \"zzzVictoria\",\n \"clientFirstName\": \"qqqGerald\",\n \"clientLastName\": \"qqqSmith\",\n \"contact\": \"zzzJeffrey Hall\",\n \"countryTypeCd\": \"CA\",\n \"declineNotificationInd\": \"N\",\n \"emailAddress\": \"lorna.trent@gov.bc.ca\",\n \"faxNumber\": \"250-638-9694\",\n \"firstName\": \"zzzLorna\",\n \"lastName\": \"zzzTrent\",\n \"middleName\": null,\n \"partyId\": 1051,\n \"phoneNumber\": \"250-635-7342\",\n \"postalCd\": \"V9E 4S3\",\n \"stateProvinceCd\": \"BC\"\n },\n \"comments\": [],\n \"consentFlag\": null,\n \"corpNum\": null,\n \"expirationDate\": null,\n \"furnished\": \"N\",\n \"hasBeenReset\": false,\n \"id\": 1051,\n \"lastUpdate\": \"Thu, 20 Sep 2018 23:02:17 GMT\",\n \"names\": [\n {\n \"choice\": 1,\n \"comment\": null,\n \"conflict1\": null,\n \"conflict1_num\": null,\n \"conflict2\": null,\n \"conflict2_num\": null,\n \"conflict3\": null,\n \"conflict3_num\": null,\n \"consumptionDate\": null,\n \"decision_text\": null,\n \"name\": \"STRANGWAY & SONS ACCOUNTING SERVICES\",\n \"state\": \"NE\"\n },\n\t\t{\n\t\t\t\"choice\": 2,\n\t\t\t\"comment\": null,\n\t\t\t\"conflict1\": \"\",\n\t\t\t\"conflict1_num\": \"\",\n\t\t\t\"conflict2\": \"\",\n\t\t\t\"conflict2_num\": \"\",\n\t\t\t\"conflict3\": \"\",\n\t\t\t\"conflict3_num\": \"\",\n\t\t\t\"consumptionDate\": null,\n\t\t\t\"decision_text\": \"\",\n\t\t\t\"name\": \"\",\n\t\t\t\"state\": \"NE\"\n\t\t},\n\t\t{\n\t\t\t\"choice\": 3,\n\t\t\t\"comment\": null,\n\t\t\t\"conflict1\": \"\",\n\t\t\t\"conflict1_num\": \"\",\n\t\t\t\"conflict2\": \"\",\n\t\t\t\"conflict2_num\": \"\",\n\t\t\t\"conflict3\": \"\",\n\t\t\t\"conflict3_num\": \"\",\n\t\t\t\"consumptionDate\": null,\n\t\t\t\"decision_text\": \"\",\n\t\t\t\"name\": \"\",\n\t\t\t\"state\": \"NE\"\n\t\t}\n\t],\n \"natureBusinessInfo\": \"Corporate Accounting Firm\",\n \"nrNum\": \"NR 2943527\",\n \"nwpta\": [],\n \"previousNr\": null,\n \"priorityCd\": \"Y\",\n\t\"priorityDate\": \"Fri, 07 Dec 2018 11:26:51 GMT\",\n \"requestTypeCd\": \"XCR\",\n \"state\": \"INPROGRESS\",\n \"submitCount\": 1,\n \"submittedDate\": \"Thu, 20 Sep 2018 10:27:55 GMT\",\n \"submitter_userid\": \"\",\n \"userId\": \"postman\",\n \"xproJurisdiction\": \"NEW BRUNSWICK\"\n}" + }, + "url": { + "raw": "{{url}}/api/v1/requests/{{NR}}", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "v1", + "requests", + "{{NR}}" + ] + } + }, + "response": [] + }, + { + "name": "requests/NR - check values reset", + "event": [ + { + "listen": "test", + "script": { + "id": "c1429a8d-6bf6-485e-a78f-3401419da30d", + "exec": [ + "eval(globals.postmanBDD);", + "", + "pm.test(\"Response time is less than 5000ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(5000);", + "});", + "", + "it('should be an success response', () => {", + " response.ok.should.be.true; // 2XX", + " response.error.should.be.false; // 4XX or 5XX", + " response.clientError.should.be.false; // 4XX", + " response.serverError.should.be.false; // 5XX", + " response.should.have.status(200);", + " response.statusType.should.equal(2);", + "});", + "", + "it('should return JSON', () => {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "it('should contain the un-parsed JSON text', () => {", + " response.text.should.be.a('string').with.length.above(10);", + "});", + "", + "it(\"Should return the required fields for an NR\", () => {", + " response.body.should.be.an('object').with.keys(['additionalInfo','applicants','comments','consentFlag','corpNum', 'expirationDate','furnished','hasBeenReset','id','lastUpdate','names','natureBusinessInfo','nrNum','nwpta','previousNr', 'previousRequestId','previousStateCd', 'priorityCd','priorityDate','requestTypeCd','state','submitCount','submittedDate','submitter_userid','userId', 'xproJurisdiction']);", + "});", + "", + "for (var i=0; i {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "it('should be an unsuccessful response', () => {", + " response.ok.should.be.false; // 2XX", + " response.error.should.be.true; // 4XX or 5XX", + " response.clientError.should.be.true; // 4XX", + " response.serverError.should.be.false; // 5XX", + " response.statusType.should.equal(4);", + " response.should.have.status(400);", + "});", + "", + "it('should contain the un-parsed JSON text', () => {", + " response.text.should.be.a('string').with.length.above(10);", + "});", + "", + "it(\"Should return an error message\", () => {", + " response.body.should.be.an('object').with.keys(['message']);", + " response.body.message.should.include('Data does not include a name choice 1');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "id": "f8801a4b-3dcb-414e-a1f2-8f32e35abfaf", + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{token}}" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"additionalInfo\": \"This is additional info entered by the applicant.\",\n \"applicants\": {\n \"addrLine1\": \"zzz1571 ABBOTT ST\",\n \"addrLine2\": null,\n \"addrLine3\": null,\n \"city\": \"zzzVictoria\",\n \"clientFirstName\": \"qqqGerald\",\n \"clientLastName\": \"qqqSmith\",\n \"contact\": \"zzzJeffrey Hall\",\n \"countryTypeCd\": \"CA\",\n \"declineNotificationInd\": \"N\",\n \"emailAddress\": \"lorna.trent@gov.bc.ca\",\n \"faxNumber\": \"250-638-9694\",\n \"firstName\": \"zzzLorna\",\n \"lastName\": \"zzzTrent\",\n \"middleName\": null,\n \"partyId\": 1051,\n \"phoneNumber\": \"250-635-7342\",\n \"postalCd\": \"V9E 4S3\",\n \"stateProvinceCd\": \"BC\"\n },\n \"comments\": [],\n \"consentFlag\": null,\n \"corpNum\": null,\n \"expirationDate\": null,\n \"furnished\": \"N\",\n \"hasBeenReset\": false,\n \"id\": 1051,\n \"lastUpdate\": \"Thu, 20 Sep 2018 23:02:17 GMT\",\n \"names\": [\n {\n \"choice\": 1,\n \"comment\": null,\n \"conflict1\": null,\n \"conflict1_num\": null,\n \"conflict2\": null,\n \"conflict2_num\": null,\n \"conflict3\": null,\n \"conflict3_num\": null,\n \"consumptionDate\": null,\n \"decision_text\": null,\n \"name\": \"\",\n \"state\": \"NE\"\n },\n\t\t{\n\t\t\t\"choice\": 2,\n\t\t\t\"comment\": null,\n\t\t\t\"conflict1\": \"\",\n\t\t\t\"conflict1_num\": \"\",\n\t\t\t\"conflict2\": \"\",\n\t\t\t\"conflict2_num\": \"\",\n\t\t\t\"conflict3\": \"\",\n\t\t\t\"conflict3_num\": \"\",\n\t\t\t\"consumptionDate\": null,\n\t\t\t\"decision_text\": \"\",\n\t\t\t\"name\": \"Should not get added\",\n\t\t\t\"state\": \"NE\"\n\t\t},\n\t\t{\n\t\t\t\"choice\": 3,\n\t\t\t\"comment\": null,\n\t\t\t\"conflict1\": \"\",\n\t\t\t\"conflict1_num\": \"\",\n\t\t\t\"conflict2\": \"\",\n\t\t\t\"conflict2_num\": \"\",\n\t\t\t\"conflict3\": \"\",\n\t\t\t\"conflict3_num\": \"\",\n\t\t\t\"consumptionDate\": null,\n\t\t\t\"decision_text\": \"\",\n\t\t\t\"name\": \"Should not get added\",\n\t\t\t\"state\": \"NE\"\n\t\t}\n\t],\n \"natureBusinessInfo\": \"Corporate Accounting Firm\",\n \"nrNum\": \"NR 2943527\",\n \"nwpta\": [],\n \"previousNr\": null,\n \"priorityCd\": \"Y\",\n\t\"priorityDate\": \"Fri, 07 Dec 2018 11:26:51 GMT\",\n \"requestTypeCd\": \"XCR\",\n \"state\": \"INPROGRESS\",\n \"submitCount\": 1,\n \"submittedDate\": \"Thu, 20 Sep 2018 10:27:55 GMT\",\n \"submitter_userid\": \"\",\n \"userId\": \"postman\",\n \"xproJurisdiction\": \"NEW BRUNSWICK\"\n}" + }, + "url": { + "raw": "{{url}}/api/v1/requests/{{NR}}", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "v1", + "requests", + "{{NR}}" + ] + } + }, + "response": [] + }, + { + "name": "/requests - try adding name3 without name2", + "event": [ + { + "listen": "test", + "script": { + "id": "63511ee5-c76d-46c6-b98d-76384b834a99", + "exec": [ + "eval(globals.postmanBDD);", + "", + "pm.test(\"Response time is less than 5000ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(5000);", + "});", + "", + "it('should return JSON', () => {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "it('should be an unsuccessful response', () => {", + " response.ok.should.be.false; // 2XX", + " response.error.should.be.true; // 4XX or 5XX", + " response.clientError.should.be.true; // 4XX", + " response.serverError.should.be.false; // 5XX", + " response.statusType.should.equal(4);", + " response.should.have.status(400);", + "});", + "", + "it('should contain the un-parsed JSON text', () => {", + " response.text.should.be.a('string').with.length.above(10);", + "});", + "", + "it(\"Should return an error message\", () => {", + " response.body.should.be.an('object').with.keys(['message']);", + " response.body.message.should.include('Data contains a name choice 3 without a name choice 2');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "id": "f8801a4b-3dcb-414e-a1f2-8f32e35abfaf", + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{token}}" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"additionalInfo\": \"This is additional info entered by the applicant.\",\n \"applicants\": {\n \"addrLine1\": \"zzz1571 ABBOTT ST\",\n \"addrLine2\": null,\n \"addrLine3\": null,\n \"city\": \"zzzVictoria\",\n \"clientFirstName\": \"qqqGerald\",\n \"clientLastName\": \"qqqSmith\",\n \"contact\": \"zzzJeffrey Hall\",\n \"countryTypeCd\": \"CA\",\n \"declineNotificationInd\": \"N\",\n \"emailAddress\": \"lorna.trent@gov.bc.ca\",\n \"faxNumber\": \"250-638-9694\",\n \"firstName\": \"zzzLorna\",\n \"lastName\": \"zzzTrent\",\n \"middleName\": null,\n \"partyId\": 1051,\n \"phoneNumber\": \"250-635-7342\",\n \"postalCd\": \"V9E 4S3\",\n \"stateProvinceCd\": \"BC\"\n },\n \"comments\": [],\n \"consentFlag\": null,\n \"corpNum\": null,\n \"expirationDate\": null,\n \"furnished\": \"N\",\n \"hasBeenReset\": false,\n \"id\": 1051,\n \"lastUpdate\": \"Thu, 20 Sep 2018 23:02:17 GMT\",\n \"names\": [\n {\n \"choice\": 1,\n \"comment\": null,\n \"conflict1\": null,\n \"conflict1_num\": null,\n \"conflict2\": null,\n \"conflict2_num\": null,\n \"conflict3\": null,\n \"conflict3_num\": null,\n \"consumptionDate\": null,\n \"decision_text\": null,\n \"name\": \"STRANGWAY & SONS ACCOUNTING SERVICES\",\n \"state\": \"NE\"\n },\n\t\t{\n\t\t\t\"choice\": 2,\n\t\t\t\"comment\": null,\n\t\t\t\"conflict1\": \"\",\n\t\t\t\"conflict1_num\": \"\",\n\t\t\t\"conflict2\": \"\",\n\t\t\t\"conflict2_num\": \"\",\n\t\t\t\"conflict3\": \"\",\n\t\t\t\"conflict3_num\": \"\",\n\t\t\t\"consumptionDate\": null,\n\t\t\t\"decision_text\": \"\",\n\t\t\t\"name\": \"\",\n\t\t\t\"state\": \"NE\"\n\t\t},\n\t\t{\n\t\t\t\"choice\": 3,\n\t\t\t\"comment\": null,\n\t\t\t\"conflict1\": \"\",\n\t\t\t\"conflict1_num\": \"\",\n\t\t\t\"conflict2\": \"\",\n\t\t\t\"conflict2_num\": \"\",\n\t\t\t\"conflict3\": \"\",\n\t\t\t\"conflict3_num\": \"\",\n\t\t\t\"consumptionDate\": null,\n\t\t\t\"decision_text\": \"\",\n\t\t\t\"name\": \"Should not get added\",\n\t\t\t\"state\": \"NE\"\n\t\t}\n\t],\n \"natureBusinessInfo\": \"Corporate Accounting Firm\",\n \"nrNum\": \"NR 2943527\",\n \"nwpta\": [],\n \"previousNr\": null,\n \"priorityCd\": \"Y\",\n\t\"priorityDate\": \"Fri, 07 Dec 2018 11:26:51 GMT\",\n \"requestTypeCd\": \"XCR\",\n \"state\": \"INPROGRESS\",\n \"submitCount\": 1,\n \"submittedDate\": \"Thu, 20 Sep 2018 10:27:55 GMT\",\n \"submitter_userid\": \"\",\n \"userId\": \"postman\",\n \"xproJurisdiction\": \"NEW BRUNSWICK\"\n}" + }, + "url": { + "raw": "{{url}}/api/v1/requests/{{NR}}", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "v1", + "requests", + "{{NR}}" + ] + } + }, + "response": [] + }, + { + "name": "requests/NR - check no values were changed", + "event": [ + { + "listen": "test", + "script": { + "id": "c1429a8d-6bf6-485e-a78f-3401419da30d", + "exec": [ + "eval(globals.postmanBDD);", + "", + "pm.test(\"Response time is less than 5000ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(5000);", + "});", + "", + "it('should be an success response', () => {", + " response.ok.should.be.true; // 2XX", + " response.error.should.be.false; // 4XX or 5XX", + " response.clientError.should.be.false; // 4XX", + " response.serverError.should.be.false; // 5XX", + " response.should.have.status(200);", + " response.statusType.should.equal(2);", + "});", + "", + "it('should return JSON', () => {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "it('should contain the un-parsed JSON text', () => {", + " response.text.should.be.a('string').with.length.above(10);", + "});", + "", + "it(\"Should return the required fields for an NR\", () => {", + " response.body.should.be.an('object').with.keys(['additionalInfo','applicants','comments','consentFlag','corpNum', 'expirationDate','furnished','hasBeenReset','id','lastUpdate','names','natureBusinessInfo','nrNum','nwpta','previousNr', 'previousRequestId','previousStateCd', 'priorityCd','priorityDate','requestTypeCd','state','submitCount','submittedDate','submitter_userid','userId', 'xproJurisdiction']);", + "});", + "", + "for (var i=0; i {", + " response.ok.should.be.true; // 2XX", + " response.error.should.be.false; // 4XX or 5XX", + " response.clientError.should.be.false; // 4XX", + " response.serverError.should.be.false; // 5XX", + " response.should.have.status(200);", + " response.statusType.should.equal(2);", + "});", + "", + "it('Should return JSON', () => {", + " response.should.be.json;", + " response.should.have.header('Content-Type', 'application/json');", + " response.type.should.equal('application/json');", + "});", + "", + "var jsonData = pm.response.json();", + "it('Should contain \\'message\\' confirming patch', () => {", + " response.body.should.be.an('object').with.keys(['message']);", + " jsonData.message.should.include('- patched');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{token}}" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\"state\": \"HOLD\"}" + }, + "url": { + "raw": "{{url}}/api/v1/requests/{{NR}}", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "v1", + "requests", + "{{NR}}" + ] + } + }, + "response": [] + } + ] + }, { "name": "requests+names", "item": [