diff --git a/postman-tests/Create/New user/test.js b/postman-tests/Create/New user/test.js deleted file mode 100644 index 4fea0bd..0000000 --- a/postman-tests/Create/New user/test.js +++ /dev/null @@ -1,46 +0,0 @@ -const _ = require('lodash') -const res = pm.response.json() -const uniq = require('uniq') -const common = require('../../common') - -console.log(uniq([1, 1, 1, 1, 2, 3])) -common.log() - -pm.test('Status code is 200', () => { - pm.response.to.have.status(200) -}) - -pm.test('API response is successful', () => { - pm.expect(res.status).to.eql('success') -}) - -pm.test('Created user has correct type of user ID', () => { - pm.expect(res.id).to.be.a('string') -}) - -pm.test('Does not expose user password', () => { - pm.expect(res).to.not.have.property('password') -}) - -pm.test('Created user has all relevant fields', () => { - pm.expect(res).to.have.all.keys('status', 'id', 'firstName', 'lastName') -}) - -pm.test('Created user matches submitted user', () => { - const requestedUser = _.omit(rawToObject(pm.request.body.urlencoded.toString()), 'password') - const response = _.omit(res, ['id', 'status']) - pm.expect(requestedUser).to.eql(response) -}) - -pm.sendRequest({ - url: `${pm.environment.get('url')}/delete?id=${res.id}`, - method: 'delete' -}) - -function rawToObject (str) { - return str.split('&').reduce((prev, curr, i, arr) => { - var p = curr.split('=') - prev[decodeURIComponent(p[0])] = decodeURIComponent(p[1]) - return prev - }, {}) -} diff --git a/postman-tests/Delete/Delete user/preRequest.js b/postman-tests/Delete/Delete user/preRequest.js deleted file mode 100644 index 1cf3a25..0000000 --- a/postman-tests/Delete/Delete user/preRequest.js +++ /dev/null @@ -1,17 +0,0 @@ -const firstName = pm.variables.get('firstName') -const lastName = pm.variables.get('lastName') -const password = pm.variables.get('password') - -pm.sendRequest({ - url: `${pm.environment.get('url')}/create`, - method: 'POST', - header: 'Content-Type:application/x-www-form-urlencoded', - body: { - mode: 'raw', - raw: `firstName=${firstName}&lastName=${lastName}&password=${password}` - } -}, (err, res) => { - if (err) console.log(err) - res = res.json() - pm.globals.set('id', res.id) -}) diff --git a/postman-tests/Delete/Delete user/test.js b/postman-tests/Delete/Delete user/test.js deleted file mode 100644 index c4db266..0000000 --- a/postman-tests/Delete/Delete user/test.js +++ /dev/null @@ -1,32 +0,0 @@ -const response = pm.response -const id = pm.globals.get('id') - -pm.test('Status code is 200', () => { - pm.response.to.have.status(200) -}) - -pm.test('Operation is successful', () => { - const res = response.json() - pm.expect(res.status).to.eql('success') -}) - -pm.test('User matches requested user', () => { - const res = response.json() - pm.globals.set('apiKey', res.id) - pm.expect(res.id).to.eql(id) -}) - -pm.test('User can no longer be found', () => { - pm.sendRequest({ - url: `${pm.environment.get('url')}/get?id=${id}`, - header: 'x-mock-response-name:Get user by ID (no user found)', - method: 'get' - }, (err, res) => { - if (err) console.log(err) - res = res.json() - pm.expect(res.status).to.eql('no user found') - }) -}) - -// cleanup -pm.globals.unset('id') diff --git a/postman-tests/Read/Get all users/preRequest.js b/postman-tests/Read/Get all users/preRequest.js deleted file mode 100644 index 1cf3a25..0000000 --- a/postman-tests/Read/Get all users/preRequest.js +++ /dev/null @@ -1,17 +0,0 @@ -const firstName = pm.variables.get('firstName') -const lastName = pm.variables.get('lastName') -const password = pm.variables.get('password') - -pm.sendRequest({ - url: `${pm.environment.get('url')}/create`, - method: 'POST', - header: 'Content-Type:application/x-www-form-urlencoded', - body: { - mode: 'raw', - raw: `firstName=${firstName}&lastName=${lastName}&password=${password}` - } -}, (err, res) => { - if (err) console.log(err) - res = res.json() - pm.globals.set('id', res.id) -}) diff --git a/postman-tests/Read/Get all users/test.js b/postman-tests/Read/Get all users/test.js deleted file mode 100644 index 4a17b4a..0000000 --- a/postman-tests/Read/Get all users/test.js +++ /dev/null @@ -1,32 +0,0 @@ -const res = pm.response.json() -const id = pm.globals.get('id') - -pm.test('Status code is 200', () => { - pm.response.to.have.status(200) -}) - -pm.test('One user exists', () => { - pm.expect(res).to.have.length(2) -}) - -pm.test('User has all relevant fields', () => { - res.forEach((val, i) => { - if (i > 0) { - pm.expect(val).to.have.all.keys('id', 'firstName', 'lastName') - } - }) -}) - -pm.test('User passwords are not exposed', () => { - res.forEach((val) => { - pm.expect(val).to.not.have.property('password') - }) -}) - -// cleanup -pm.globals.unset('id') - -pm.sendRequest({ - url: `${pm.environment.get('url')}/delete?id=${id}`, - method: 'delete' -}) diff --git a/postman-tests/Read/Get user by ID/preRequest.js b/postman-tests/Read/Get user by ID/preRequest.js deleted file mode 100644 index 1cf3a25..0000000 --- a/postman-tests/Read/Get user by ID/preRequest.js +++ /dev/null @@ -1,17 +0,0 @@ -const firstName = pm.variables.get('firstName') -const lastName = pm.variables.get('lastName') -const password = pm.variables.get('password') - -pm.sendRequest({ - url: `${pm.environment.get('url')}/create`, - method: 'POST', - header: 'Content-Type:application/x-www-form-urlencoded', - body: { - mode: 'raw', - raw: `firstName=${firstName}&lastName=${lastName}&password=${password}` - } -}, (err, res) => { - if (err) console.log(err) - res = res.json() - pm.globals.set('id', res.id) -}) diff --git a/postman-tests/Read/Get user by ID/test.js b/postman-tests/Read/Get user by ID/test.js deleted file mode 100644 index cc37cea..0000000 --- a/postman-tests/Read/Get user by ID/test.js +++ /dev/null @@ -1,31 +0,0 @@ -const res = pm.response.json() -const id = pm.globals.get('id') - -pm.test('Status code is 200', () => { - pm.response.to.have.status(200) -}) - -pm.test('User matches requested user', () => { - const id = pm.request.url.query.get('id') - pm.expect(res[1].id).to.eql(id) -}) - -pm.test('User has correct type of user ID', () => { - pm.expect(res[1].id).to.be.a('string') -}) - -pm.test('Does not expose user password', () => { - pm.expect(res[1]).to.not.have.property('password') -}) - -pm.test('User has all relevant fields', () => { - pm.expect(res[1]).to.have.all.keys('id', 'firstName', 'lastName') -}) - -// cleanup -pm.globals.unset('id') - -pm.sendRequest({ - url: `${pm.environment.get('url')}/delete?id=${id}`, - method: 'delete' -}) diff --git a/postman-tests/Read/Get users by first name/preRequest.js b/postman-tests/Read/Get users by first name/preRequest.js deleted file mode 100644 index 1cf3a25..0000000 --- a/postman-tests/Read/Get users by first name/preRequest.js +++ /dev/null @@ -1,17 +0,0 @@ -const firstName = pm.variables.get('firstName') -const lastName = pm.variables.get('lastName') -const password = pm.variables.get('password') - -pm.sendRequest({ - url: `${pm.environment.get('url')}/create`, - method: 'POST', - header: 'Content-Type:application/x-www-form-urlencoded', - body: { - mode: 'raw', - raw: `firstName=${firstName}&lastName=${lastName}&password=${password}` - } -}, (err, res) => { - if (err) console.log(err) - res = res.json() - pm.globals.set('id', res.id) -}) diff --git a/postman-tests/Read/Get users by first name/test.js b/postman-tests/Read/Get users by first name/test.js deleted file mode 100644 index a4a133f..0000000 --- a/postman-tests/Read/Get users by first name/test.js +++ /dev/null @@ -1,45 +0,0 @@ -const res = pm.response.json() -const id = pm.globals.get('id') -const firstName = pm.variables.get('firstName') - -pm.test('Status code is 200', () => { - pm.response.to.have.status(200) -}) - -pm.test('List of users is returned', () => { - pm.expect(res).to.be.an('array') -}) - -pm.test('All users have firstname: ' + firstName, () => { - res.forEach((val, i) => { - if (i > 0) { - pm.expect(val.firstName).to.eql(firstName) - } - }) -}) - -pm.test('User passwords are not exposed', () => { - res.forEach((val, i) => { - if (i > 0) { - pm.expect(val).to.not.have.all.keys('password') - } - }) -}) - -pm.test('User has all relevant fields and correct types', () => { - res.forEach((val, i) => { - if (i > 0) { - pm.expect(val.id).to.be.a('string') - pm.expect(val.firstName).to.be.a('string') - pm.expect(val.lastName).to.be.a('string') - } - }) -}) - -// cleanup -pm.globals.unset('id') - -pm.sendRequest({ - url: `${pm.environment.get('url')}/delete?id=${id}`, - method: 'delete' -}) diff --git a/postman-tests/Update/Update user/preRequest.js b/postman-tests/Update/Update user/preRequest.js deleted file mode 100644 index 1cf3a25..0000000 --- a/postman-tests/Update/Update user/preRequest.js +++ /dev/null @@ -1,17 +0,0 @@ -const firstName = pm.variables.get('firstName') -const lastName = pm.variables.get('lastName') -const password = pm.variables.get('password') - -pm.sendRequest({ - url: `${pm.environment.get('url')}/create`, - method: 'POST', - header: 'Content-Type:application/x-www-form-urlencoded', - body: { - mode: 'raw', - raw: `firstName=${firstName}&lastName=${lastName}&password=${password}` - } -}, (err, res) => { - if (err) console.log(err) - res = res.json() - pm.globals.set('id', res.id) -}) diff --git a/postman-tests/Update/Update user/test.js b/postman-tests/Update/Update user/test.js deleted file mode 100644 index 999ceaa..0000000 --- a/postman-tests/Update/Update user/test.js +++ /dev/null @@ -1,43 +0,0 @@ -const res = pm.response.json() -const id = pm.request.url.query.get('id') -const firstName = pm.request.body.urlencoded.get('firstName') - -pm.test('Status code is 200', () => { - pm.response.to.have.status(200) -}) - -if (res.status === 'success') { - pm.test('User matches requested user', () => { - pm.expect(res.id).to.eql(id) - }) - - pm.test('User has correct type of user ID', () => { - pm.expect(res.id).to.be.a('string') - }) - - pm.test('User has all relevant fields', () => { - pm.expect(res).to.have.all.keys('status', 'id', 'firstName', 'lastName') - }) - - pm.test('Does not expose user password', () => { - pm.expect(res).to.not.have.property('password') - }) - - pm.test('First name is updated to: ' + firstName, () => { - pm.expect(res.firstName).to.eql(firstName) - }) -} else if (res.status === 'no user found') { - pm.test('Lookup was against correct user', () => { - pm.expect(res.id).to.eql(id) - }) -} else { - pm.test(res.status).to.eql('invalid request') -} - -// cleanup -pm.globals.unset('id') - -pm.sendRequest({ - url: `${pm.environment.get('url')}/delete?id=${id}`, - method: 'delete' -}) diff --git a/postman-tests/common.js b/postman-tests/common.js deleted file mode 100644 index 3688a38..0000000 --- a/postman-tests/common.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - log: () => { - console.log('hello world') - } -}