From 035d1044350d48d73a8c652cd92c161a3cb5e1aa Mon Sep 17 00:00:00 2001 From: Tony Rasa Date: Thu, 2 Jan 2025 11:30:48 -0800 Subject: [PATCH 1/5] removing raw, mode --- examples/CS261_Assignment2_Putter.json | 1670 ++++++++++++++++++++++++ 1 file changed, 1670 insertions(+) create mode 100644 examples/CS261_Assignment2_Putter.json diff --git a/examples/CS261_Assignment2_Putter.json b/examples/CS261_Assignment2_Putter.json new file mode 100644 index 0000000..6069cdc --- /dev/null +++ b/examples/CS261_Assignment2_Putter.json @@ -0,0 +1,1670 @@ +{ + "info": { + "version": "2.0", + "name": "CS261 Assignment 2" + }, + "item": [ + { + "name": "Creating a user with POST on users/", + "item": [ + { + "name": "Create succeeds with a new user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = pm.response.json();\r", + "\r", + "pm.test(\"status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test('should return a user ID', function() {\r", + " pm.expect(jsonData).to.have.property('id');\r", + " pm.expect(jsonData.id).to.not.be.empty;\r", + "});\r", + "\r", + "pm.test('should return the username', function() {\r", + " pm.expect(jsonData).to.have.property('username');\r", + " pm.expect(jsonData.username).to.equal(pm.environment.get(\"testUser\"));\r", + "});\r", + "\r", + "pm.test('should return the password', function() {\r", + " pm.expect(jsonData).to.have.property('password');\r", + " pm.expect(jsonData.password).to.equal(pm.environment.get(\"testPassword\"));\r", + "});\r", + "\r", + "pm.test('should return the avatar', function() {\r", + " pm.expect(jsonData).to.have.property('avatar');\r", + " pm.expect(jsonData.avatar).to.equal(pm.environment.get(\"testAvatar\"));\r", + "});\r", + "\r", + "pm.test('ID is not the same as the username', function() {\r", + " pm.expect(jsonData.username).to.not.equal(jsonData.id);\r", + "});\r", + "\r", + "pm.test('ID is not the same as the password', function() {\r", + " pm.expect(jsonData.password).to.not.equal(jsonData.id);\r", + "});\r", + "\r", + "pm.test('ID is not the same as the avatar', function() {\r", + " pm.expect(jsonData.avatar).to.not.equal(jsonData.id);\r", + "});\r", + "\r", + "pm.environment.set(\"userId\", jsonData.id);" + ] + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var digits = '' + Math.floor((Math.random() * 100000));", + "pm.environment.set(\"testUser\", \"user\" + digits);", + "pm.environment.set(\"testPassword\", \"password\" + digits);", + "pm.environment.set(\"testAvatar\", \"avi\" + digits);" + ] + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/" + } + }, + "response": [] + }, + { + "name": "Create succeeds with distinct second user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = pm.response.json();\r", + "\r", + "pm.test(\"status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test('should return a user ID', function() {\r", + " pm.expect(jsonData).to.have.property('id');\r", + " pm.expect(jsonData.id).to.not.be.empty;\r", + "});\r", + "\r", + "pm.test('should not have the same user ID as the first user', function() {\r", + " pm.expect(jsonData).to.have.property('id');\r", + " pm.expect(jsonData.id).to.not.equal(pm.environment.get('userId'));\r", + "});\r", + "\r", + "pm.test('should return the correct username', function() {\r", + " pm.expect(jsonData).to.have.property('username');\r", + " pm.expect(jsonData.username).to.equal(pm.environment.get(\"otherUser\"));\r", + "});\r", + "\r", + "pm.environment.set(\"otherUserId\", jsonData.id);" + ] + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var digits = '' + Math.floor(Math.random() * 100000);", + "pm.environment.set(\"otherUser\", \"user\" + digits);", + "pm.environment.set(\"otherPassword\", \"password\" + digits);", + "pm.environment.set(\"otherAvatar\", \"avi\" + digits);" + ] + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"username\": \"{{otherUser}}\",\n\"password\": \"{{otherPassword}}\",\n\"avatar\": \"{{otherAvatar}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/" + } + }, + "response": [] + }, + { + "name": "Create fails with duplicate user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 409\", function () {\r", + " pm.response.to.have.status(409);\r", + "});" + ] + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "Login with POST to login/", + "item": [ + { + "name": "Login succeeds with the first user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "let jsonData = JSON.parse(responseBody);\r", + "\r", + "pm.test(\"status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test('should return a session', function() {\r", + " pm.expect(jsonData).to.have.property('session');\r", + " pm.expect(jsonData.session).to.not.be.empty;\r", + "});\r", + "\r", + "pm.test('user ID and session should not be the same', function() {\r", + " pm.expect(jsonData.session).to.not.be.equal(pm.environment.get(\"userId\"));\r", + "});\r", + "\r", + "pm.test('username and session should not be the same', function() {\r", + " pm.expect(jsonData.session).to.not.be.equal(pm.environment.get(\"testUser\"));\r", + "});\r", + "\r", + "pm.test('password and session should not be the same', function() {\r", + " pm.expect(jsonData.session).to.not.be.equal(pm.environment.get(\"testPassword\"));\r", + "});\r", + "\r", + "pm.environment.set(\"session\", jsonData.session);\r", + "pm.environment.set(\"originalSession\", jsonData.session);" + ] + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/login" + } + }, + "response": [] + }, + { + "name": "Login succeeds with a second login with different session", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "let jsonData = JSON.parse(responseBody);\r", + "\r", + "pm.test(\"status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test('should return a session', function() {\r", + " pm.expect(jsonData).to.have.property('session');\r", + " pm.expect(jsonData.session).to.not.be.empty;\r", + "});\r", + "\r", + "pm.test('new session ID is different from old session ID', function() {\r", + " pm.expect(jsonData.session).to.not.be.equal(pm.environment.get(\"session\"));\r", + "});\r", + "\r", + "pm.environment.set(\"session\", jsonData.session);" + ] + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/login" + } + }, + "response": [] + }, + { + "name": "Login succeeds with second user with different session/token", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "let jsonData = JSON.parse(responseBody);\r", + "\r", + "pm.test(\"status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test('should return a session', function() {\r", + " pm.expect(jsonData).to.have.property('session');\r", + " pm.expect(jsonData.session).to.not.be.empty;\r", + "});\r", + "\r", + "pm.test('session should not match the first user session', function() {\r", + " pm.expect(jsonData.session).to.not.be.equal(pm.environment.get(\"session\"));\r", + "});\r", + "\r", + "pm.environment.set(\"otherSession\", jsonData.session);" + ] + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"username\": \"{{otherUser}}\",\n\"password\": \"{{otherPassword}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/login" + } + }, + "response": [] + }, + { + "name": "Login fails with bad password", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 403\", function () {\r", + " pm.response.to.have.status(403);\r", + "});" + ] + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}{{testPassword}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/login", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "login" + ] + } + }, + "response": [] + }, + { + "name": "Login fails with bad username", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 400\", function () {\r", + " pm.response.to.have.status(400);\r", + "});" + ] + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"username\": \"{{testUser}}{{testUser}}\",\n\"password\": \"{{testPassword}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/login", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "login" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "Retrieve a user by ID with GET on users/:id", + "item": [ + { + "name": "Retrieving the same user succeeds", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);\r", + "\r", + "pm.test(\"status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test('should return test user id', function() {\r", + " pm.expect(jsonData).to.have.property('id');\r", + " pm.expect(jsonData.id).to.eql(pm.environment.get(\"userId\"));\r", + "});\r", + "\r", + "pm.test('should return test username', function() {\r", + " pm.expect(jsonData).to.have.property('username');\r", + " pm.expect(jsonData.username).to.eql(pm.environment.get(\"testUser\"));\r", + "});\r", + "\r", + "pm.test('should return test password', function() {\r", + " pm.expect(jsonData).to.have.property('password');\r", + " pm.expect(jsonData.password).to.eql(pm.environment.get(\"testPassword\"));\r", + "});\r", + "\r", + "pm.test('should return test user avatar', function() {\r", + " pm.expect(jsonData).to.have.property('avatar');\r", + " pm.expect(jsonData.avatar).to.eql(pm.environment.get(\"testAvatar\"));\r", + "});" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users", + "{{userId}}" + ] + } + }, + "response": [] + }, + { + "name": "Retrieving a different user succeeds", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);\r", + "\r", + "pm.test(\"status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test('should return other user id', function() {\r", + " pm.expect(jsonData).to.have.property('id');\r", + " pm.expect(jsonData.id).to.eql(pm.environment.get(\"otherUserId\"));\r", + "});\r", + "\r", + "pm.test('should return other username', function() {\r", + " pm.expect(jsonData).to.have.property('username');\r", + " pm.expect(jsonData.username).to.eql(pm.environment.get(\"otherUser\"));\r", + "});\r", + "\r", + "pm.test('should return other avatar', function() {\r", + " pm.expect(jsonData).to.have.property('avatar');\r", + " pm.expect(jsonData.avatar).to.eql(pm.environment.get(\"otherAvatar\"));\r", + "});\r", + "\r", + "pm.test('should not return other password', function() {\r", + " pm.expect(jsonData).not.to.have.property('password');\r", + "});" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users", + "{{otherUserId}}" + ] + } + }, + "response": [] + }, + { + "name": "Retrieving fails with no session", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 401\", function () {\r", + " pm.response.to.have.status(401);\r", + "});" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "raw": "" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users", + "{{userId}}" + ] + } + }, + "response": [] + }, + { + "name": "Retrieving fails with bad session", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 401\", function () {\r", + " pm.response.to.have.status(401);\r", + "});\r", + "" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users", + "{{userId}}" + ] + } + }, + "response": [] + }, + { + "name": "Retrieving fails with old session", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 401\", function () {\r", + " pm.response.to.have.status(401);\r", + "});\r", + "" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{originalSession}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users", + "{{userId}}" + ] + } + }, + "response": [] + }, + { + "name": "Retrieving fails with bad ID (valid session)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 404\", function () {\r", + " pm.response.to.have.status(404);\r", + "});" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/xxx{{otherUserId}}xxx", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users", + "xxx{{otherUserId}}xxx" + ] + } + }, + "response": [] + }, + { + "name": "Retrieving fails with bad ID (bad session)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 401\", function () {\r", + " pm.response.to.have.status(401);\r", + "});" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/xxx{{otherUserId}}xxx", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users", + "xxx{{otherUserId}}xxx" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "Searching for a user by name with GET on users", + "item": [ + { + "name": "Searching for self succeeds", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);\r", + "\r", + "pm.test(\"status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test('should return test user id', function() {\r", + " pm.expect(jsonData).to.have.property('id');\r", + " pm.expect(jsonData.id).to.eql(pm.environment.get(\"userId\"));\r", + "});\r", + "\r", + "pm.test('should return test username', function() {\r", + " pm.expect(jsonData).to.have.property('username');\r", + " pm.expect(jsonData.username).to.eql(pm.environment.get(\"testUser\"));\r", + "});\r", + "\r", + "pm.test('should return test user avatar', function() {\r", + " pm.expect(jsonData).to.have.property('avatar');\r", + " pm.expect(jsonData.avatar).to.eql(pm.environment.get(\"testAvatar\"));\r", + "});\r", + "\r", + "pm.test('should return test user password', function() {\r", + " pm.expect(jsonData).to.have.property('password');\r", + "});\r", + "" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users?username={{testUser}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users" + ], + "query": [ + { + "key": "username", + "value": "{{testUser}}" + } + ] + } + }, + "response": [] + }, + { + "name": "Searching for a different user succeeds", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);\r", + "\r", + "pm.test(\"status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test('should return other user id', function() {\r", + " pm.expect(jsonData).to.have.property('id');\r", + " pm.expect(jsonData.id).to.eql(pm.environment.get(\"otherUserId\"));\r", + "});\r", + "\r", + "pm.test('should return other username', function() {\r", + " pm.expect(jsonData).to.have.property('username');\r", + " pm.expect(jsonData.username).to.eql(pm.environment.get(\"otherUser\"));\r", + "});\r", + "\r", + "pm.test('should return other avatar', function() {\r", + " pm.expect(jsonData).to.have.property('avatar');\r", + " pm.expect(jsonData.avatar).to.eql(pm.environment.get(\"otherAvatar\"));\r", + "});\r", + "\r", + "pm.test('should not return other password', function() {\r", + " pm.expect(jsonData).not.to.have.property('password');\r", + "});" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users" + ], + "query": [ + { + "key": "username", + "value": "{{otherUser}}" + } + ] + } + }, + "response": [] + }, + { + "name": "Searching fails with no session", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 401\", function () {\r", + " pm.response.to.have.status(401);\r", + "});" + ] + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "raw": "" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users" + ], + "query": [ + { + "key": "username", + "value": "{{otherUser}}" + } + ] + } + }, + "response": [] + }, + { + "name": "Searching fails with bad session", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 401\", function () {\r", + " pm.response.to.have.status(401);\r", + "});" + ] + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users" + ], + "query": [ + { + "key": "username", + "value": "{{otherUser}}" + } + ] + } + }, + "response": [] + }, + { + "name": "Searching fails with bad username (valid session)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 404\", function () {\r", + " pm.response.to.have.status(404);\r", + "});" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users?username=xx{{testUser}}xx", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users" + ], + "query": [ + { + "key": "username", + "value": "xx{{testUser}}xx" + } + ] + } + }, + "response": [] + }, + { + "name": "Searching fails with bad username (bad session)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 401\", function () {\r", + " pm.response.to.have.status(401);\r", + "});" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users?username=xx{{testUser}}xx", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users" + ], + "query": [ + { + "key": "username", + "value": "xx{{testUser}}xx" + } + ] + } + }, + "response": [] + }, + { + "name": "Searching fails with no username (valid session)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 400\", function () {\r", + " pm.response.to.have.status(400);\r", + "});" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "Updating a user by ID with PUT on users/:id", + "item": [ + { + "name": "Updating succeeds with new data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);\r", + "\r", + "pm.test(\"status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test('should return the new username', function() {\r", + " pm.expect(jsonData).to.have.property('username');\r", + " pm.expect(jsonData.username).to.equal(pm.environment.get(\"newUser\"));\r", + "});\r", + "\r", + "pm.test('should return the new password', function() {\r", + " pm.expect(jsonData).to.have.property('password');\r", + " pm.expect(jsonData.password).to.equal(pm.environment.get(\"newPassword\"));\r", + "});\r", + "\r", + "pm.test('should return the new avatar', function() {\r", + " pm.expect(jsonData).to.have.property('avatar');\r", + " pm.expect(jsonData.avatar).to.equal(pm.environment.get(\"newAvatar\"));\r", + "});" + ] + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var digits = '' + Math.floor((Math.random() * 100000));", + "pm.environment.set(\"newUser\", \"user\" + digits);", + "pm.environment.set(\"newPassword\", \"password\" + digits);", + "pm.environment.set(\"newAvatar\", \"avi\" + digits);" + ] + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}\",\n\"username\": \"{{newUser}}\",\n\"password\": \"{{newPassword}}\",\n\"avatar\": \"{{newAvatar}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users", + "{{userId}}" + ] + } + }, + "response": [] + }, + { + "name": "Updating fails on different user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 403\", function () {\r", + " pm.response.to.have.status(403);\r", + "});" + ] + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ] + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}\",\n\"avatar\": \"{{newAvatar}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users", + "{{otherUserId}}" + ] + } + }, + "response": [] + }, + { + "name": "Updating fails with no session", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 401\", function () {\r", + " pm.response.to.have.status(401);\r", + "});" + ] + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ] + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users", + "{{userId}}" + ] + } + }, + "response": [] + }, + { + "name": "Updating fails with bad session", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 401\", function () {\r", + " pm.response.to.have.status(401);\r", + "});" + ] + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ] + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}{{session}}\",\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users", + "{{userId}}" + ] + } + }, + "response": [] + }, + { + "name": "Updating fails with bad username (valid session)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 404\", function () {\r", + " pm.response.to.have.status(404);\r", + "});" + ] + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ] + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}\",\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/xx{{userId}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users", + "xx{{userId}}" + ] + } + }, + "response": [] + }, + { + "name": "Updating fails with bad username (bad session)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"status code is 401\", function () {\r", + " pm.response.to.have.status(401);\r", + "});" + ] + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ] + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}{{session}}\",\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/xx{{userId}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users", + "xx{{userId}}" + ] + } + }, + "response": [] + }, + { + "name": "Changes to first user persist after failed calls", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);\r", + "\r", + "pm.test(\"status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test('should return test user id', function() {\r", + " pm.expect(jsonData).to.have.property('id');\r", + " pm.expect(jsonData.id).to.eql(pm.environment.get(\"userId\"));\r", + "});\r", + "\r", + "pm.test('should return new username', function() {\r", + " pm.expect(jsonData).to.have.property('username');\r", + " pm.expect(jsonData.username).to.eql(pm.environment.get(\"newUser\"));\r", + "});\r", + "\r", + "pm.test('should return new password', function() {\r", + " pm.expect(jsonData).to.have.property('password');\r", + " pm.expect(jsonData.password).to.eql(pm.environment.get(\"newPassword\"));\r", + "});\r", + "\r", + "pm.test('should return new avatar', function() {\r", + " pm.expect(jsonData).to.have.property('avatar');\r", + " pm.expect(jsonData.avatar).to.eql(pm.environment.get(\"newAvatar\"));\r", + "});" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users", + "{{userId}}" + ] + } + }, + "response": [] + }, + { + "name": "No changes to other user after failed calls", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);\r", + "\r", + "pm.test(\"status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test('should return test user id', function() {\r", + " pm.expect(jsonData).to.have.property('id');\r", + " pm.expect(jsonData.id).to.eql(pm.environment.get(\"otherUserId\"));\r", + "});\r", + "\r", + "pm.test('should return original username', function() {\r", + " pm.expect(jsonData).to.have.property('username');\r", + " pm.expect(jsonData.username).to.eql(pm.environment.get(\"otherUser\"));\r", + "});\r", + "\r", + "pm.test('should return original avatar', function() {\r", + " pm.expect(jsonData).to.have.property('avatar');\r", + " pm.expect(jsonData.avatar).to.eql(pm.environment.get(\"otherAvatar\"));\r", + "});\r", + "\r", + "pm.test('should not return password', function() {\r", + " pm.expect(jsonData).to.not.have.property('password');\r", + "});" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "raw": "{\n\"session\": \"{{session}}\"\n}" + }, + "url": { + "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}", + "protocol": "http", + "host": [ + "{{address}}" + ], + "port": "{{port}}", + "path": [ + "api", + "v1", + "users", + "{{otherUserId}}" + ] + } + }, + "response": [] + } + ] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "key": "port", + "value": "3100" + }, + { + "key": "address", + "value": "localhost" + } + ] +} \ No newline at end of file From e2c2930c485ffd8137dd00d2a07a8869d5570817 Mon Sep 17 00:00:00 2001 From: Tony Rasa Date: Thu, 2 Jan 2025 11:36:49 -0800 Subject: [PATCH 2/5] removed more unused fields --- examples/CS261_Assignment2_Putter.json | 441 +++---------------------- 1 file changed, 55 insertions(+), 386 deletions(-) diff --git a/examples/CS261_Assignment2_Putter.json b/examples/CS261_Assignment2_Putter.json index 6069cdc..a5924f5 100644 --- a/examples/CS261_Assignment2_Putter.json +++ b/examples/CS261_Assignment2_Putter.json @@ -82,8 +82,7 @@ "url": { "raw": "http://{{address}}:{{port}}/api/v1/users/" } - }, - "response": [] + } }, { "name": "Create succeeds with distinct second user", @@ -143,8 +142,7 @@ "url": { "raw": "http://{{address}}:{{port}}/api/v1/users/" } - }, - "response": [] + } }, { "name": "Create fails with duplicate user", @@ -172,20 +170,9 @@ "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users" } - }, - "response": [] + } } ] }, @@ -242,8 +229,7 @@ "url": { "raw": "http://{{address}}:{{port}}/api/v1/login" } - }, - "response": [] + } }, { "name": "Login succeeds with a second login with different session", @@ -286,8 +272,7 @@ "url": { "raw": "http://{{address}}:{{port}}/api/v1/login" } - }, - "response": [] + } }, { "name": "Login succeeds with second user with different session/token", @@ -330,8 +315,7 @@ "url": { "raw": "http://{{address}}:{{port}}/api/v1/login" } - }, - "response": [] + } }, { "name": "Login fails with bad password", @@ -359,20 +343,9 @@ "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}{{testPassword}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/login", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "login" - ] + "raw": "http://{{address}}:{{port}}/api/v1/login" } - }, - "response": [] + } }, { "name": "Login fails with bad username", @@ -400,20 +373,9 @@ "raw": "{\n\"username\": \"{{testUser}}{{testUser}}\",\n\"password\": \"{{testPassword}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/login", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "login" - ] + "raw": "http://{{address}}:{{port}}/api/v1/login" } - }, - "response": [] + } } ] }, @@ -471,21 +433,9 @@ "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" } - }, - "response": [] + } }, { "name": "Retrieving a different user succeeds", @@ -537,21 +487,9 @@ "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{otherUserId}}" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}" } - }, - "response": [] + } }, { "name": "Retrieving fails with no session", @@ -577,21 +515,9 @@ "raw": "" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" } - }, - "response": [] + } }, { "name": "Retrieving fails with bad session", @@ -623,21 +549,9 @@ "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" } - }, - "response": [] + } }, { "name": "Retrieving fails with old session", @@ -669,21 +583,9 @@ "raw": "{\n\"session\": \"{{originalSession}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" } - }, - "response": [] + } }, { "name": "Retrieving fails with bad ID (valid session)", @@ -714,21 +616,9 @@ "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/xxx{{otherUserId}}xxx", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "xxx{{otherUserId}}xxx" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users/xxx{{otherUserId}}xxx" } - }, - "response": [] + } }, { "name": "Retrieving fails with bad ID (bad session)", @@ -759,21 +649,9 @@ "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/xxx{{otherUserId}}xxx", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "xxx{{otherUserId}}xxx" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users/xxx{{otherUserId}}xxx" } - }, - "response": [] + } } ] }, @@ -831,26 +709,9 @@ "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username={{testUser}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "{{testUser}}" - } - ] + "raw": "http://{{address}}:{{port}}/api/v1/users?username={{testUser}}" } - }, - "response": [] + } }, { "name": "Searching for a different user succeeds", @@ -902,26 +763,9 @@ "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "{{otherUser}}" - } - ] + "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}" } - }, - "response": [] + } }, { "name": "Searching fails with no session", @@ -955,26 +799,9 @@ "raw": "" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "{{otherUser}}" - } - ] + "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}" } - }, - "response": [] + } }, { "name": "Searching fails with bad session", @@ -1013,26 +840,9 @@ "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "{{otherUser}}" - } - ] + "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}" } - }, - "response": [] + } }, { "name": "Searching fails with bad username (valid session)", @@ -1063,26 +873,9 @@ "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username=xx{{testUser}}xx", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "xx{{testUser}}xx" - } - ] + "raw": "http://{{address}}:{{port}}/api/v1/users?username=xx{{testUser}}xx" } - }, - "response": [] + } }, { "name": "Searching fails with bad username (bad session)", @@ -1113,26 +906,9 @@ "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username=xx{{testUser}}xx", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "xx{{testUser}}xx" - } - ] + "raw": "http://{{address}}:{{port}}/api/v1/users?username=xx{{testUser}}xx" } - }, - "response": [] + } }, { "name": "Searching fails with no username (valid session)", @@ -1163,20 +939,9 @@ "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users" } - }, - "response": [] + } } ] }, @@ -1237,21 +1002,9 @@ "raw": "{\n\"session\": \"{{session}}\",\n\"username\": \"{{newUser}}\",\n\"password\": \"{{newPassword}}\",\n\"avatar\": \"{{newAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" } - }, - "response": [] + } }, { "name": "Updating fails on different user", @@ -1287,21 +1040,9 @@ "raw": "{\n\"session\": \"{{session}}\",\n\"avatar\": \"{{newAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{otherUserId}}" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}" } - }, - "response": [] + } }, { "name": "Updating fails with no session", @@ -1337,21 +1078,9 @@ "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" } - }, - "response": [] + } }, { "name": "Updating fails with bad session", @@ -1387,21 +1116,9 @@ "raw": "{\n\"session\": \"{{session}}{{session}}\",\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" } - }, - "response": [] + } }, { "name": "Updating fails with bad username (valid session)", @@ -1437,21 +1154,9 @@ "raw": "{\n\"session\": \"{{session}}\",\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/xx{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "xx{{userId}}" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users/xx{{userId}}" } - }, - "response": [] + } }, { "name": "Updating fails with bad username (bad session)", @@ -1487,21 +1192,9 @@ "raw": "{\n\"session\": \"{{session}}{{session}}\",\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/xx{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "xx{{userId}}" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users/xx{{userId}}" } - }, - "response": [] + } }, { "name": "Changes to first user persist after failed calls", @@ -1554,21 +1247,9 @@ "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" } - }, - "response": [] + } }, { "name": "No changes to other user after failed calls", @@ -1620,21 +1301,9 @@ "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{otherUserId}}" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}" } - }, - "response": [] + } } ] } From d5094d1ef9532b7ebb905aebdb22116a0a7738fa Mon Sep 17 00:00:00 2001 From: Tony Rasa Date: Thu, 2 Jan 2025 11:46:49 -0800 Subject: [PATCH 3/5] smaller assignment2 --- ...nt2_Putter.json => CS261_Assignment2.json} | 0 examples/CS261_Assignment2_Postman.json | 1804 ----------------- 2 files changed, 1804 deletions(-) rename examples/{CS261_Assignment2_Putter.json => CS261_Assignment2.json} (100%) delete mode 100644 examples/CS261_Assignment2_Postman.json diff --git a/examples/CS261_Assignment2_Putter.json b/examples/CS261_Assignment2.json similarity index 100% rename from examples/CS261_Assignment2_Putter.json rename to examples/CS261_Assignment2.json diff --git a/examples/CS261_Assignment2_Postman.json b/examples/CS261_Assignment2_Postman.json deleted file mode 100644 index ff704d4..0000000 --- a/examples/CS261_Assignment2_Postman.json +++ /dev/null @@ -1,1804 +0,0 @@ -{ - "info": { - "_postman_id": "2b220f48-4f4d-4183-97ae-1f279dc31d71", - "name": "CS261 Assignment 2", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "Creating a user with POST on users/", - "item": [ - { - "name": "Create succeeds with a new user", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = pm.response.json();\r", - "\r", - "pm.test(\"status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('should return a user ID', function() {\r", - " pm.expect(jsonData).to.have.property('id');\r", - " pm.expect(jsonData.id).to.not.be.empty;\r", - "});\r", - "\r", - "pm.test('should return the username', function() {\r", - " pm.expect(jsonData).to.have.property('username');\r", - " pm.expect(jsonData.username).to.equal(pm.environment.get(\"testUser\"));\r", - "});\r", - "\r", - "pm.test('should return the password', function() {\r", - " pm.expect(jsonData).to.have.property('password');\r", - " pm.expect(jsonData.password).to.equal(pm.environment.get(\"testPassword\"));\r", - "});\r", - "\r", - "pm.test('should return the avatar', function() {\r", - " pm.expect(jsonData).to.have.property('avatar');\r", - " pm.expect(jsonData.avatar).to.equal(pm.environment.get(\"testAvatar\"));\r", - "});\r", - "\r", - "pm.test('ID is not the same as the username', function() {\r", - " pm.expect(jsonData.username).to.not.equal(jsonData.id);\r", - "});\r", - "\r", - "pm.test('ID is not the same as the password', function() {\r", - " pm.expect(jsonData.password).to.not.equal(jsonData.id);\r", - "});\r", - "\r", - "pm.test('ID is not the same as the avatar', function() {\r", - " pm.expect(jsonData.avatar).to.not.equal(jsonData.id);\r", - "});\r", - "\r", - "pm.environment.set(\"userId\", jsonData.id);" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "var digits = '' + Math.floor((Math.random() * 100000));", - "pm.environment.set(\"testUser\", \"user\" + digits);", - "pm.environment.set(\"testPassword\", \"password\" + digits);", - "pm.environment.set(\"testAvatar\", \"avi\" + digits);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "" - ] - } - }, - "response": [] - }, - { - "name": "Create succeeds with distinct second user", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = pm.response.json();\r", - "\r", - "pm.test(\"status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('should return a user ID', function() {\r", - " pm.expect(jsonData).to.have.property('id');\r", - " pm.expect(jsonData.id).to.not.be.empty;\r", - "});\r", - "\r", - "pm.test('should not have the same user ID as the first user', function() {\r", - " pm.expect(jsonData).to.have.property('id');\r", - " pm.expect(jsonData.id).to.not.equal(pm.environment.get('userId'));\r", - "});\r", - "\r", - "pm.test('should return the correct username', function() {\r", - " pm.expect(jsonData).to.have.property('username');\r", - " pm.expect(jsonData.username).to.equal(pm.environment.get(\"otherUser\"));\r", - "});\r", - "\r", - "pm.environment.set(\"otherUserId\", jsonData.id);" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "var digits = '' + Math.floor(Math.random() * 100000);", - "pm.environment.set(\"otherUser\", \"user\" + digits);", - "pm.environment.set(\"otherPassword\", \"password\" + digits);", - "pm.environment.set(\"otherAvatar\", \"avi\" + digits);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"username\": \"{{otherUser}}\",\n\"password\": \"{{otherPassword}}\",\n\"avatar\": \"{{otherAvatar}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "" - ] - } - }, - "response": [] - }, - { - "name": "Create fails with duplicate user", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 409\", function () {\r", - " pm.response.to.have.status(409);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Login with POST to login/", - "item": [ - { - "name": "Login succeeds with the first user", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "let jsonData = JSON.parse(responseBody);\r", - "\r", - "pm.test(\"status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('should return a session', function() {\r", - " pm.expect(jsonData).to.have.property('session');\r", - " pm.expect(jsonData.session).to.not.be.empty;\r", - "});\r", - "\r", - "pm.test('user ID and session should not be the same', function() {\r", - " pm.expect(jsonData.session).to.not.be.equal(pm.environment.get(\"userId\"));\r", - "});\r", - "\r", - "pm.test('username and session should not be the same', function() {\r", - " pm.expect(jsonData.session).to.not.be.equal(pm.environment.get(\"testUser\"));\r", - "});\r", - "\r", - "pm.test('password and session should not be the same', function() {\r", - " pm.expect(jsonData.session).to.not.be.equal(pm.environment.get(\"testPassword\"));\r", - "});\r", - "\r", - "pm.environment.set(\"session\", jsonData.session);\r", - "pm.environment.set(\"originalSession\", jsonData.session);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/login", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "login" - ] - } - }, - "response": [] - }, - { - "name": "Login succeeds with a second login with different session", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "let jsonData = JSON.parse(responseBody);\r", - "\r", - "pm.test(\"status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('should return a session', function() {\r", - " pm.expect(jsonData).to.have.property('session');\r", - " pm.expect(jsonData.session).to.not.be.empty;\r", - "});\r", - "\r", - "pm.test('new session ID is different from old session ID', function() {\r", - " pm.expect(jsonData.session).to.not.be.equal(pm.environment.get(\"session\"));\r", - "});\r", - "\r", - "pm.environment.set(\"session\", jsonData.session);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/login", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "login" - ] - } - }, - "response": [] - }, - { - "name": "Login succeeds with second user with different session/token", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "let jsonData = JSON.parse(responseBody);\r", - "\r", - "pm.test(\"status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('should return a session', function() {\r", - " pm.expect(jsonData).to.have.property('session');\r", - " pm.expect(jsonData.session).to.not.be.empty;\r", - "});\r", - "\r", - "pm.test('session should not match the first user session', function() {\r", - " pm.expect(jsonData.session).to.not.be.equal(pm.environment.get(\"session\"));\r", - "});\r", - "\r", - "pm.environment.set(\"otherSession\", jsonData.session);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"username\": \"{{otherUser}}\",\n\"password\": \"{{otherPassword}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/login", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "login" - ] - } - }, - "response": [] - }, - { - "name": "Login fails with bad password", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 403\", function () {\r", - " pm.response.to.have.status(403);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}{{testPassword}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/login", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "login" - ] - } - }, - "response": [] - }, - { - "name": "Login fails with bad username", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 400\", function () {\r", - " pm.response.to.have.status(400);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"username\": \"{{testUser}}{{testUser}}\",\n\"password\": \"{{testPassword}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/login", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "login" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Retrieve a user by ID with GET on users/:id", - "item": [ - { - "name": "Retrieving the same user succeeds", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);\r", - "\r", - "pm.test(\"status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('should return test user id', function() {\r", - " pm.expect(jsonData).to.have.property('id');\r", - " pm.expect(jsonData.id).to.eql(pm.environment.get(\"userId\"));\r", - "});\r", - "\r", - "pm.test('should return test username', function() {\r", - " pm.expect(jsonData).to.have.property('username');\r", - " pm.expect(jsonData.username).to.eql(pm.environment.get(\"testUser\"));\r", - "});\r", - "\r", - "pm.test('should return test password', function() {\r", - " pm.expect(jsonData).to.have.property('password');\r", - " pm.expect(jsonData.password).to.eql(pm.environment.get(\"testPassword\"));\r", - "});\r", - "\r", - "pm.test('should return test user avatar', function() {\r", - " pm.expect(jsonData).to.have.property('avatar');\r", - " pm.expect(jsonData.avatar).to.eql(pm.environment.get(\"testAvatar\"));\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] - }, - { - "name": "Retrieving a different user succeeds", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);\r", - "\r", - "pm.test(\"status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('should return other user id', function() {\r", - " pm.expect(jsonData).to.have.property('id');\r", - " pm.expect(jsonData.id).to.eql(pm.environment.get(\"otherUserId\"));\r", - "});\r", - "\r", - "pm.test('should return other username', function() {\r", - " pm.expect(jsonData).to.have.property('username');\r", - " pm.expect(jsonData.username).to.eql(pm.environment.get(\"otherUser\"));\r", - "});\r", - "\r", - "pm.test('should return other avatar', function() {\r", - " pm.expect(jsonData).to.have.property('avatar');\r", - " pm.expect(jsonData.avatar).to.eql(pm.environment.get(\"otherAvatar\"));\r", - "});\r", - "\r", - "pm.test('should not return other password', function() {\r", - " pm.expect(jsonData).not.to.have.property('password');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{otherUserId}}" - ] - } - }, - "response": [] - }, - { - "name": "Retrieving fails with no session", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 401\", function () {\r", - " pm.response.to.have.status(401);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [], - "body": { - "mode": "raw", - "raw": "" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] - }, - { - "name": "Retrieving fails with bad session", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 401\", function () {\r", - " pm.response.to.have.status(401);\r", - "});\r", - "" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] - }, - { - "name": "Retrieving fails with old session", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 401\", function () {\r", - " pm.response.to.have.status(401);\r", - "});\r", - "" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{originalSession}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] - }, - { - "name": "Retrieving fails with bad ID (valid session)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 404\", function () {\r", - " pm.response.to.have.status(404);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/xxx{{otherUserId}}xxx", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "xxx{{otherUserId}}xxx" - ] - } - }, - "response": [] - }, - { - "name": "Retrieving fails with bad ID (bad session)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 401\", function () {\r", - " pm.response.to.have.status(401);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/xxx{{otherUserId}}xxx", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "xxx{{otherUserId}}xxx" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Searching for a user by name with GET on users", - "item": [ - { - "name": "Searching for self succeeds", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);\r", - "\r", - "pm.test(\"status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('should return test user id', function() {\r", - " pm.expect(jsonData).to.have.property('id');\r", - " pm.expect(jsonData.id).to.eql(pm.environment.get(\"userId\"));\r", - "});\r", - "\r", - "pm.test('should return test username', function() {\r", - " pm.expect(jsonData).to.have.property('username');\r", - " pm.expect(jsonData.username).to.eql(pm.environment.get(\"testUser\"));\r", - "});\r", - "\r", - "pm.test('should return test user avatar', function() {\r", - " pm.expect(jsonData).to.have.property('avatar');\r", - " pm.expect(jsonData.avatar).to.eql(pm.environment.get(\"testAvatar\"));\r", - "});\r", - "\r", - "pm.test('should return test user password', function() {\r", - " pm.expect(jsonData).to.have.property('password');\r", - "});\r", - "" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username={{testUser}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "{{testUser}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Searching for a different user succeeds", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);\r", - "\r", - "pm.test(\"status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('should return other user id', function() {\r", - " pm.expect(jsonData).to.have.property('id');\r", - " pm.expect(jsonData.id).to.eql(pm.environment.get(\"otherUserId\"));\r", - "});\r", - "\r", - "pm.test('should return other username', function() {\r", - " pm.expect(jsonData).to.have.property('username');\r", - " pm.expect(jsonData.username).to.eql(pm.environment.get(\"otherUser\"));\r", - "});\r", - "\r", - "pm.test('should return other avatar', function() {\r", - " pm.expect(jsonData).to.have.property('avatar');\r", - " pm.expect(jsonData.avatar).to.eql(pm.environment.get(\"otherAvatar\"));\r", - "});\r", - "\r", - "pm.test('should not return other password', function() {\r", - " pm.expect(jsonData).not.to.have.property('password');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "{{otherUser}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Searching fails with no session", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 401\", function () {\r", - " pm.response.to.have.status(401);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [], - "body": { - "mode": "raw", - "raw": "" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "{{otherUser}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Searching fails with bad session", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 401\", function () {\r", - " pm.response.to.have.status(401);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "{{otherUser}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Searching fails with bad username (valid session)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 404\", function () {\r", - " pm.response.to.have.status(404);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username=xx{{testUser}}xx", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "xx{{testUser}}xx" - } - ] - } - }, - "response": [] - }, - { - "name": "Searching fails with bad username (bad session)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 401\", function () {\r", - " pm.response.to.have.status(401);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username=xx{{testUser}}xx", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "xx{{testUser}}xx" - } - ] - } - }, - "response": [] - }, - { - "name": "Searching fails with no username (valid session)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 400\", function () {\r", - " pm.response.to.have.status(400);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Updating a user by ID with PUT on users/:id", - "item": [ - { - "name": "Updating succeeds with new data", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);\r", - "\r", - "pm.test(\"status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('should return the new username', function() {\r", - " pm.expect(jsonData).to.have.property('username');\r", - " pm.expect(jsonData.username).to.equal(pm.environment.get(\"newUser\"));\r", - "});\r", - "\r", - "pm.test('should return the new password', function() {\r", - " pm.expect(jsonData).to.have.property('password');\r", - " pm.expect(jsonData.password).to.equal(pm.environment.get(\"newPassword\"));\r", - "});\r", - "\r", - "pm.test('should return the new avatar', function() {\r", - " pm.expect(jsonData).to.have.property('avatar');\r", - " pm.expect(jsonData.avatar).to.equal(pm.environment.get(\"newAvatar\"));\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "var digits = '' + Math.floor((Math.random() * 100000));", - "pm.environment.set(\"newUser\", \"user\" + digits);", - "pm.environment.set(\"newPassword\", \"password\" + digits);", - "pm.environment.set(\"newAvatar\", \"avi\" + digits);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}\",\n\"username\": \"{{newUser}}\",\n\"password\": \"{{newPassword}}\",\n\"avatar\": \"{{newAvatar}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] - }, - { - "name": "Updating fails on different user", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 403\", function () {\r", - " pm.response.to.have.status(403);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}\",\n\"avatar\": \"{{newAvatar}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{otherUserId}}" - ] - } - }, - "response": [] - }, - { - "name": "Updating fails with no session", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 401\", function () {\r", - " pm.response.to.have.status(401);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] - }, - { - "name": "Updating fails with bad session", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 401\", function () {\r", - " pm.response.to.have.status(401);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}{{session}}\",\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] - }, - { - "name": "Updating fails with bad username (valid session)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 404\", function () {\r", - " pm.response.to.have.status(404);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}\",\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/xx{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "xx{{userId}}" - ] - } - }, - "response": [] - }, - { - "name": "Updating fails with bad username (bad session)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"status code is 401\", function () {\r", - " pm.response.to.have.status(401);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}{{session}}\",\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/xx{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "xx{{userId}}" - ] - } - }, - "response": [] - }, - { - "name": "Changes to first user persist after failed calls", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);\r", - "\r", - "pm.test(\"status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('should return test user id', function() {\r", - " pm.expect(jsonData).to.have.property('id');\r", - " pm.expect(jsonData.id).to.eql(pm.environment.get(\"userId\"));\r", - "});\r", - "\r", - "pm.test('should return new username', function() {\r", - " pm.expect(jsonData).to.have.property('username');\r", - " pm.expect(jsonData.username).to.eql(pm.environment.get(\"newUser\"));\r", - "});\r", - "\r", - "pm.test('should return new password', function() {\r", - " pm.expect(jsonData).to.have.property('password');\r", - " pm.expect(jsonData.password).to.eql(pm.environment.get(\"newPassword\"));\r", - "});\r", - "\r", - "pm.test('should return new avatar', function() {\r", - " pm.expect(jsonData).to.have.property('avatar');\r", - " pm.expect(jsonData.avatar).to.eql(pm.environment.get(\"newAvatar\"));\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] - }, - { - "name": "No changes to other user after failed calls", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);\r", - "\r", - "pm.test(\"status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('should return test user id', function() {\r", - " pm.expect(jsonData).to.have.property('id');\r", - " pm.expect(jsonData.id).to.eql(pm.environment.get(\"otherUserId\"));\r", - "});\r", - "\r", - "pm.test('should return original username', function() {\r", - " pm.expect(jsonData).to.have.property('username');\r", - " pm.expect(jsonData.username).to.eql(pm.environment.get(\"otherUser\"));\r", - "});\r", - "\r", - "pm.test('should return original avatar', function() {\r", - " pm.expect(jsonData).to.have.property('avatar');\r", - " pm.expect(jsonData.avatar).to.eql(pm.environment.get(\"otherAvatar\"));\r", - "});\r", - "\r", - "pm.test('should not return password', function() {\r", - " pm.expect(jsonData).to.not.have.property('password');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\"session\": \"{{session}}\"\n}" - }, - "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{otherUserId}}" - ] - } - }, - "response": [] - } - ] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], - "variable": [ - { - "key": "port", - "value": "3100" - }, - { - "key": "address", - "value": "localhost" - } - ] -} \ No newline at end of file From d1193a3c7a1b913457ea9ff63eb956392404f0a2 Mon Sep 17 00:00:00 2001 From: Tony Rasa Date: Thu, 2 Jan 2025 11:47:03 -0800 Subject: [PATCH 4/5] smaller assignment3 --- .../{CS261_Assignment3_Postman.json => CS261_Assignment3.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{CS261_Assignment3_Postman.json => CS261_Assignment3.json} (100%) diff --git a/examples/CS261_Assignment3_Postman.json b/examples/CS261_Assignment3.json similarity index 100% rename from examples/CS261_Assignment3_Postman.json rename to examples/CS261_Assignment3.json From eb6b44cc01915a486d19d49aaed2a69b6a3c54d2 Mon Sep 17 00:00:00 2001 From: Tony Rasa Date: Thu, 2 Jan 2025 12:01:34 -0800 Subject: [PATCH 5/5] pruning a3 removed protocol body pruning (not implemented) --- examples/CS261_Assignment2.json | 48 -- examples/CS261_Assignment3.json | 994 +++++--------------------------- 2 files changed, 144 insertions(+), 898 deletions(-) diff --git a/examples/CS261_Assignment2.json b/examples/CS261_Assignment2.json index a5924f5..41a3b71 100644 --- a/examples/CS261_Assignment2.json +++ b/examples/CS261_Assignment2.json @@ -418,9 +418,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -472,9 +469,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -505,9 +499,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [], @@ -534,9 +525,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -568,9 +556,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -601,9 +586,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -634,9 +616,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -694,9 +673,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -748,9 +724,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -789,9 +762,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [], @@ -825,9 +795,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -858,9 +825,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -891,9 +855,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -924,9 +885,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -1232,9 +1190,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -1286,9 +1241,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ diff --git a/examples/CS261_Assignment3.json b/examples/CS261_Assignment3.json index ebe6898..1401aae 100644 --- a/examples/CS261_Assignment3.json +++ b/examples/CS261_Assignment3.json @@ -1,8 +1,7 @@ { "info": { - "_postman_id": "a6f07c94-390e-4907-afee-cd8ccf75ca17", - "name": "CS261 Assignment 3", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + "version": "2.0", + "name": "CS261 Assignment 3" }, "item": [ { @@ -54,8 +53,7 @@ "});\r", "\r", "pm.environment.set(\"userId\", jsonData.id);" - ], - "type": "text/javascript" + ] } }, { @@ -66,8 +64,7 @@ "pm.environment.set(\"testUser\", \"user\" + digits);", "pm.environment.set(\"testPassword\", \"password\" + digits);", "pm.environment.set(\"testAvatar\", \"avi\" + digits);" - ], - "type": "text/javascript" + ] } } ], @@ -80,25 +77,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/" + } + } }, { "name": "Create succeeds with distinct second user", @@ -129,8 +113,7 @@ "});\r", "\r", "pm.environment.set(\"otherUserId\", jsonData.id);" - ], - "type": "text/javascript" + ] } }, { @@ -141,8 +124,7 @@ "pm.environment.set(\"otherUser\", \"user\" + digits);", "pm.environment.set(\"otherPassword\", \"password\" + digits);", "pm.environment.set(\"otherAvatar\", \"avi\" + digits);" - ], - "type": "text/javascript" + ] } } ], @@ -155,25 +137,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"username\": \"{{otherUser}}\",\n\"password\": \"{{otherPassword}}\",\n\"avatar\": \"{{otherAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/" + } + } }, { "name": "Create fails with duplicate user", @@ -185,17 +154,7 @@ "pm.test(\"status code is 409\", function () {\r", " pm.response.to.have.status(409);\r", "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" + ] } } ], @@ -208,24 +167,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users" + } + } } ] }, @@ -264,8 +211,7 @@ "\r", "pm.environment.set(\"session\", jsonData.session);\r", "pm.environment.set(\"originalSession\", jsonData.session);" - ], - "type": "text/javascript" + ] } } ], @@ -278,24 +224,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/login", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "login" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/login" + } + } }, { "name": "Login succeeds with a second login with different session", @@ -320,8 +254,7 @@ "});\r", "\r", "pm.environment.set(\"session\", jsonData.session);" - ], - "type": "text/javascript" + ] } } ], @@ -334,27 +267,15 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/login", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "login" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/login" + } + } }, { - "name": "Login succeeds with second user with different session", + "name": "Login succeeds with second user with different session/token", "event": [ { "listen": "test", @@ -376,8 +297,7 @@ "});\r", "\r", "pm.environment.set(\"otherSession\", jsonData.session);" - ], - "type": "text/javascript" + ] } } ], @@ -390,24 +310,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"username\": \"{{otherUser}}\",\n\"password\": \"{{otherPassword}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/login", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "login" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/login" + } + } }, { "name": "Login fails with bad password", @@ -419,8 +327,7 @@ "pm.test(\"status code is 403\", function () {\r", " pm.response.to.have.status(403);\r", "});" - ], - "type": "text/javascript" + ] } } ], @@ -433,24 +340,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}{{testPassword}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/login", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "login" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/login" + } + } }, { "name": "Login fails with bad username", @@ -462,8 +357,7 @@ "pm.test(\"status code is 400\", function () {\r", " pm.response.to.have.status(400);\r", "});" - ], - "type": "text/javascript" + ] } } ], @@ -476,24 +370,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"username\": \"{{testUser}}{{testUser}}\",\n\"password\": \"{{testPassword}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/login", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "login" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/login" + } + } } ] }, @@ -532,14 +414,10 @@ " pm.expect(jsonData).to.have.property('avatar');\r", " pm.expect(jsonData.avatar).to.eql(pm.environment.get(\"testAvatar\"));\r", "});" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -549,25 +427,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" + } + } }, { "name": "Retrieving a different user succeeds", @@ -600,14 +465,10 @@ "pm.test('should not return other password', function() {\r", " pm.expect(jsonData).not.to.have.property('password');\r", "});" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -617,25 +478,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{otherUserId}}" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}" + } + } }, { "name": "Retrieving fails with no session", @@ -647,37 +495,20 @@ "pm.test(\"status code is 401\", function () {\r", " pm.response.to.have.status(401);\r", "});" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [], "body": { - "mode": "raw", "raw": "" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" + } + } }, { "name": "Retrieving fails with bad session", @@ -690,14 +521,10 @@ " pm.response.to.have.status(401);\r", "});\r", "" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -707,25 +534,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" + } + } }, { "name": "Retrieving fails with old session", @@ -738,14 +552,10 @@ " pm.response.to.have.status(401);\r", "});\r", "" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -755,25 +565,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{originalSession}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" + } + } }, { "name": "Retrieving fails with bad ID (valid session)", @@ -785,14 +582,10 @@ "pm.test(\"status code is 404\", function () {\r", " pm.response.to.have.status(404);\r", "});" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -802,25 +595,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/xxx{{otherUserId}}xxx", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "xxx{{otherUserId}}xxx" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/xxx{{otherUserId}}xxx" + } + } }, { "name": "Retrieving fails with bad ID (bad session)", @@ -832,14 +612,10 @@ "pm.test(\"status code is 401\", function () {\r", " pm.response.to.have.status(401);\r", "});" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -849,25 +625,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/xxx{{otherUserId}}xxx", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "xxx{{otherUserId}}xxx" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/xxx{{otherUserId}}xxx" + } + } } ] }, @@ -906,14 +669,10 @@ " pm.expect(jsonData).to.have.property('password');\r", "});\r", "" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -923,30 +682,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username={{testUser}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "{{testUser}}" - } - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users?username={{testUser}}" + } + } }, { "name": "Searching for a different user succeeds", @@ -979,14 +720,10 @@ "pm.test('should not return other password', function() {\r", " pm.expect(jsonData).not.to.have.property('password');\r", "});" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -996,30 +733,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "{{otherUser}}" - } - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}" + } + } }, { "name": "Searching fails with no session", @@ -1031,51 +750,20 @@ "pm.test(\"status code is 401\", function () {\r", " pm.response.to.have.status(401);\r", "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [], "body": { - "mode": "raw", "raw": "" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "{{otherUser}}" - } - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}" + } + } }, { "name": "Searching fails with bad session", @@ -1087,23 +775,10 @@ "pm.test(\"status code is 401\", function () {\r", " pm.response.to.have.status(401);\r", "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -1113,30 +788,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "{{otherUser}}" - } - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users?username={{otherUser}}" + } + } }, { "name": "Searching fails with bad username (valid session)", @@ -1148,14 +805,10 @@ "pm.test(\"status code is 404\", function () {\r", " pm.response.to.have.status(404);\r", "});" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -1165,30 +818,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username=xx{{testUser}}xx", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "xx{{testUser}}xx" - } - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users?username=xx{{testUser}}xx" + } + } }, { "name": "Searching fails with bad username (bad session)", @@ -1200,14 +835,10 @@ "pm.test(\"status code is 401\", function () {\r", " pm.response.to.have.status(401);\r", "});" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -1217,30 +848,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username=xx{{testUser}}xx", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "xx{{testUser}}xx" - } - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users?username=xx{{testUser}}xx" + } + } }, { "name": "Searching fails with no username (valid session)", @@ -1252,14 +865,10 @@ "pm.test(\"status code is 400\", function () {\r", " pm.response.to.have.status(400);\r", "});" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -1269,24 +878,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users" + } + } } ] }, @@ -1320,8 +917,7 @@ " pm.expect(jsonData).to.have.property('avatar');\r", " pm.expect(jsonData.avatar).to.equal(pm.environment.get(\"newAvatar\"));\r", "});" - ], - "type": "text/javascript" + ] } }, { @@ -1332,8 +928,7 @@ "pm.environment.set(\"newUser\", \"user\" + digits);", "pm.environment.set(\"newPassword\", \"password\" + digits);", "pm.environment.set(\"newAvatar\", \"avi\" + digits);" - ], - "type": "text/javascript" + ] } } ], @@ -1346,25 +941,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}\",\n\"username\": \"{{newUser}}\",\n\"password\": \"{{newPassword}}\",\n\"avatar\": \"{{newAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" + } + } }, { "name": "Updating fails on different user", @@ -1376,17 +958,7 @@ "pm.test(\"status code is 403\", function () {\r", " pm.response.to.have.status(403);\r", "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" + ] } } ], @@ -1399,25 +971,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}\",\n\"avatar\": \"{{newAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{otherUserId}}" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}" + } + } }, { "name": "Updating fails with no session", @@ -1429,17 +988,7 @@ "pm.test(\"status code is 401\", function () {\r", " pm.response.to.have.status(401);\r", "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" + ] } } ], @@ -1452,25 +1001,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" + } + } }, { "name": "Updating fails with bad session", @@ -1482,17 +1018,7 @@ "pm.test(\"status code is 401\", function () {\r", " pm.response.to.have.status(401);\r", "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" + ] } } ], @@ -1505,25 +1031,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}{{session}}\",\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" + } + } }, { "name": "Updating fails with bad username (valid session)", @@ -1535,17 +1048,7 @@ "pm.test(\"status code is 404\", function () {\r", " pm.response.to.have.status(404);\r", "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" + ] } } ], @@ -1558,25 +1061,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}\",\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/xx{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "xx{{userId}}" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/xx{{userId}}" + } + } }, { "name": "Updating fails with bad username (bad session)", @@ -1588,17 +1078,7 @@ "pm.test(\"status code is 401\", function () {\r", " pm.response.to.have.status(401);\r", "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" + ] } } ], @@ -1611,25 +1091,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}{{session}}\",\n\"username\": \"{{testUser}}\",\n\"password\": \"{{testPassword}}\",\n\"avatar\": \"{{testAvatar}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/xx{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "xx{{userId}}" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/xx{{userId}}" + } + } }, { "name": "Changes to first user persist after failed calls", @@ -1663,14 +1130,10 @@ " pm.expect(jsonData).to.have.property('avatar');\r", " pm.expect(jsonData.avatar).to.eql(pm.environment.get(\"newAvatar\"));\r", "});" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -1680,25 +1143,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{userId}}" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{userId}}" + } + } }, { "name": "No changes to other user after failed calls", @@ -1731,14 +1181,10 @@ "pm.test('should not return password', function() {\r", " pm.expect(jsonData).to.not.have.property('password');\r", "});" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -1748,25 +1194,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users", - "{{otherUserId}}" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users/{{otherUserId}}" + } + } } ] }, @@ -1793,14 +1226,10 @@ "exec": [ "// wait 10.5 seconds (in milliseconds)", "setTimeout(function(){}, 10500); " - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -1810,30 +1239,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username={{newUser}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "{{newUser}}" - } - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users?username={{newUser}}" + } + } }, { "name": "Re-log in with the first user succeeds again with a new session", @@ -1859,8 +1270,7 @@ "\r", "// update the session with the new value\r", "pm.environment.set(\"session\", jsonData.session);" - ], - "type": "text/javascript" + ] } } ], @@ -1873,24 +1283,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"username\": \"{{newUser}}\",\n\"password\": \"{{newPassword}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/login", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "login" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/login" + } + } }, { "name": "Authenticated request succeeds after fresh log-in", @@ -1914,9 +1312,6 @@ } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -1926,30 +1321,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"session\": \"{{session}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username={{newUser}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "{{newUser}}" - } - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/users?username={{newUser}}" + } + } }, { "name": "Prep: re-log in with the first user to invalidate the previous", @@ -1978,8 +1355,7 @@ "\r", "// update the session with the new value\r", "pm.environment.set(\"session\", jsonData.session);" - ], - "type": "text/javascript" + ] } } ], @@ -1992,24 +1368,12 @@ } ], "body": { - "mode": "raw", "raw": "{\n\"username\": \"{{newUser}}\",\n\"password\": \"{{newPassword}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/login", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "login" - ] - } - }, - "response": [] + "raw": "http://{{address}}:{{port}}/api/v1/login" + } + } }, { "name": "Authenticated request fails with an old valid session", @@ -2021,23 +1385,10 @@ "pm.test(\"status code is 401\", function () {\r", " pm.response.to.have.status(401);\r", "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" + ] } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -2051,70 +1402,13 @@ "raw": "{\n\"session\": \"{{oldSession}}\"\n}" }, "url": { - "raw": "http://{{address}}:{{port}}/api/v1/users?username={{newUser}}", - "protocol": "http", - "host": [ - "{{address}}" - ], - "port": "{{port}}", - "path": [ - "api", - "v1", - "users" - ], - "query": [ - { - "key": "username", - "value": "{{newUser}}" - } - ] - } - }, - "response": [] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] + "raw": "http://{{address}}:{{port}}/api/v1/users?username={{newUser}}" + } } } ] } ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], "variable": [ { "key": "port",