diff --git a/TaskNoteBruno/Authentication/0-Signup new user.bru b/TaskNoteBruno/Authentication/0-Signup new user.bru new file mode 100644 index 0000000..b8be80d --- /dev/null +++ b/TaskNoteBruno/Authentication/0-Signup new user.bru @@ -0,0 +1,42 @@ +meta { + name: 0-Signup new user + type: http + seq: 1 +} + +put { + url: {{addr}}/auth/sign-up + body: json + auth: inherit +} + +body:json { + { + "email": "{{testEmail}}", + "password": "Teste@123.,", + "passwordAgain": "Teste@123.,", + "lang": "en" + } +} + +script:pre-request { + const testEmail = `test_${Date.now()}@example.com`; + const testUsername = `test_user_${Date.now()}`; + + bru.setVar("testEmail", testEmail); +} + +tests { + test("Status code is 204", function() { + expect(res.getStatus()).to.equal(204); + }); + + test("Response time is acceptable", function() { + expect(res.getResponseTime()).to.be.below(3000); + }); + +} + +settings { + encodeUrl: true +} diff --git a/TaskNoteBruno/Authentication/1-Signup duplicate user.bru b/TaskNoteBruno/Authentication/1-Signup duplicate user.bru new file mode 100644 index 0000000..f49f4ef --- /dev/null +++ b/TaskNoteBruno/Authentication/1-Signup duplicate user.bru @@ -0,0 +1,46 @@ +meta { + name: 1-Signup duplicate user + type: http + seq: 2 +} + +put { + url: {{addr}}/auth/sign-up + body: json + auth: inherit +} + +body:json { + { + "email": "{{testEmail}}", + "password": "Teste@123.,", + "passwordAgain": "Teste@123.,", + "lang": "en" + } +} + +tests { + test("Status code is 409", function() { + expect(res.getStatus()).to.equal(409); + }); + + test("Response time is acceptable", function() { + expect(res.getResponseTime()).to.be.below(3000); + }); + + test("Content type is JSON", function() { + expect(res.getHeader('content-type')).to.contain('application/json'); + }); + + test("Response has data property", function() { + const body = res.getBody(); + expect(body).to.have.property('error'); + expect(body).to.have.property('message'); + expect(body.message).to.equal('Email already exists!'); + bru.setVar("authToken", body.token); + }); +} + +settings { + encodeUrl: true +} diff --git a/TaskNoteBruno/Authentication/2-Sign in user.bru b/TaskNoteBruno/Authentication/2-Sign in user.bru new file mode 100644 index 0000000..c36b4d2 --- /dev/null +++ b/TaskNoteBruno/Authentication/2-Sign in user.bru @@ -0,0 +1,63 @@ +meta { + name: 2-Sign in user + type: http + seq: 3 +} + +post { + url: {{addr}}/auth/sign-in + body: json + auth: inherit +} + +body:json { + { + "email": "{{testEmail}}", + "password": "Teste@123.,", + "passwordAgain": "Teste@123.,", + "lang": "en" + } +} + +tests { + test("Status code is 200", function() { + expect(res.getStatus()).to.equal(200); + }); + + test("Response time is acceptable", function() { + expect(res.getResponseTime()).to.be.below(3000); + }); + + test("Content type is JSON", function() { + expect(res.getHeader('content-type')).to.contain('application/json'); + }); + + test("Response has all data well set and defined", function() { + const body = res.getBody(); + + expect(body).to.have.property('userId'); + expect(body).to.have.property('name'); + expect(body).to.have.property('email'); + expect(body).to.have.property('admin'); + expect(body).to.have.property('createdAt'); + expect(body).to.have.property('inactivatedAt'); + expect(body).to.have.property('gravatarImageUrl'); + expect(body).to.have.property('token'); + expect(body).to.have.property('lang'); + + expect(body.userId).to.be.greaterThan(0); + expect(body.name).to.be.null; + expect(body.email).to.equal(bru.getVar("testEmail")); + expect(body.admin).to.equal(false); + expect(body.createdAt).to.not.be.null; + expect(body.inactivatedAt).to.be.null; + expect(body.gravatarImageUrl).to.not.be.null; + expect(body.token).to.not.be.null; + expect(body.lang).to.equal('en'); + bru.setVar("authToken", body.token); + }); +} + +settings { + encodeUrl: true +} diff --git a/TaskNoteBruno/Authentication/3-Sign in user wrong pw.bru b/TaskNoteBruno/Authentication/3-Sign in user wrong pw.bru new file mode 100644 index 0000000..dc63280 --- /dev/null +++ b/TaskNoteBruno/Authentication/3-Sign in user wrong pw.bru @@ -0,0 +1,53 @@ +meta { + name: 3-Sign in user wrong pw + type: http + seq: 4 +} + +post { + url: {{addr}}/auth/sign-in + body: json + auth: inherit +} + +body:json { + { + "email": "{{testEmail}}", + "password": "Teste@123.,11", + "lang": "en" + } +} + +tests { + test("Status code is 401", function() { + expect(res.getStatus()).to.equal(401); + }); + + test("Response time is acceptable", function() { + expect(res.getResponseTime()).to.be.below(3000); + }); + + test("Content type is JSON", function() { + expect(res.getHeader('content-type')).to.contain('application/json'); + }); + + test("Response has all data well set and defined", function() { + const body = res.getBody(); + + expect(body).to.have.property('timestamp'); + expect(body).to.have.property('status'); + expect(body).to.have.property('error'); + expect(body).to.have.property('message'); + expect(body).to.have.property('path'); + + expect(body.timestamp).to.not.be.null; + expect(body.status).to.equal(401); + expect(body.error).to.equal('Unauthorized'); + expect(body.message).to.equal('Invalid credentials'); + expect(body.path).to.equal('/auth/sign-in'); + }); +} + +settings { + encodeUrl: true +} diff --git a/TaskNoteBruno/Authentication/Confirm Password Reset.bru b/TaskNoteBruno/Authentication/Confirm Password Reset.bru new file mode 100644 index 0000000..b72c8fe --- /dev/null +++ b/TaskNoteBruno/Authentication/Confirm Password Reset.bru @@ -0,0 +1,23 @@ +meta { + name: Confirm Password Reset + type: http + seq: 8 +} + +post { + url: {{addr}}/auth/complete-password-reset + body: json + auth: inherit +} + +body:json { + { + "token": "string", + "password": "string", + "passwordAgain": "string" + } +} + +settings { + encodeUrl: true +} diff --git a/TaskNoteBruno/Authentication/Email Confirmation.bru b/TaskNoteBruno/Authentication/Email Confirmation.bru new file mode 100644 index 0000000..25b54d7 --- /dev/null +++ b/TaskNoteBruno/Authentication/Email Confirmation.bru @@ -0,0 +1,21 @@ +meta { + name: Email Confirmation + type: http + seq: 7 +} + +post { + url: {{addr}}/auth/email-confirmation + body: json + auth: inherit +} + +body:json { + { + "email": "ricardompcampos@gmail.com" + } +} + +settings { + encodeUrl: true +} diff --git a/TaskNoteBruno/Authentication/ReSend Email.bru b/TaskNoteBruno/Authentication/ReSend Email.bru new file mode 100644 index 0000000..2adc27a --- /dev/null +++ b/TaskNoteBruno/Authentication/ReSend Email.bru @@ -0,0 +1,21 @@ +meta { + name: ReSend Email + type: http + seq: 5 +} + +post { + url: {{addr}}/auth/resend-email-confirmation + body: json + auth: inherit +} + +body:json { + { + "email": "ricardompcampos@gmail.com" + } +} + +settings { + encodeUrl: true +} diff --git a/TaskNoteBruno/Authentication/Reset Password.bru b/TaskNoteBruno/Authentication/Reset Password.bru new file mode 100644 index 0000000..916e97b --- /dev/null +++ b/TaskNoteBruno/Authentication/Reset Password.bru @@ -0,0 +1,21 @@ +meta { + name: Reset Password + type: http + seq: 6 +} + +post { + url: {{addr}}/auth/password-reset + body: json + auth: inherit +} + +body:json { + { + "email": "ricardompcampos@gmail.com" + } +} + +settings { + encodeUrl: true +} diff --git a/TaskNoteBruno/Authentication/folder.bru b/TaskNoteBruno/Authentication/folder.bru new file mode 100644 index 0000000..d6d201a --- /dev/null +++ b/TaskNoteBruno/Authentication/folder.bru @@ -0,0 +1,8 @@ +meta { + name: Authentication + seq: 2 +} + +auth { + mode: inherit +} diff --git a/TaskNoteBruno/Home/5-Get tags empty.bru b/TaskNoteBruno/Home/5-Get tags empty.bru new file mode 100644 index 0000000..a2d2c46 --- /dev/null +++ b/TaskNoteBruno/Home/5-Get tags empty.bru @@ -0,0 +1,26 @@ +meta { + name: 5-Get tags empty + type: http + seq: 3 +} + +get { + url: {{addr}}/rest/home/tasks/tags + body: none + auth: none +} + +headers { + Authorization: Bearer {{authToken}} +} + +tests { + test("Response is an empty array", function() { + const body = res.getBody(); + expect(body).to.be.an('array').that.is.empty; + }); +} + +settings { + encodeUrl: true +} diff --git a/TaskNoteBruno/Home/folder.bru b/TaskNoteBruno/Home/folder.bru new file mode 100644 index 0000000..f184e5e --- /dev/null +++ b/TaskNoteBruno/Home/folder.bru @@ -0,0 +1,8 @@ +meta { + name: Home + seq: 4 +} + +auth { + mode: inherit +} diff --git a/TaskNoteBruno/Session/Refresh.bru b/TaskNoteBruno/Session/Refresh.bru new file mode 100644 index 0000000..c941da0 --- /dev/null +++ b/TaskNoteBruno/Session/Refresh.bru @@ -0,0 +1,15 @@ +meta { + name: Refresh + type: http + seq: 1 +} + +get { + url: {{addr}}/rest/user-sessions/refresh + body: none + auth: inherit +} + +settings { + encodeUrl: true +} diff --git a/TaskNoteBruno/Session/folder.bru b/TaskNoteBruno/Session/folder.bru new file mode 100644 index 0000000..2cbca34 --- /dev/null +++ b/TaskNoteBruno/Session/folder.bru @@ -0,0 +1,8 @@ +meta { + name: Session + seq: 2 +} + +auth { + mode: inherit +} diff --git a/TaskNoteBruno/Task/folder.bru b/TaskNoteBruno/Task/folder.bru new file mode 100644 index 0000000..58f936d --- /dev/null +++ b/TaskNoteBruno/Task/folder.bru @@ -0,0 +1,8 @@ +meta { + name: Task + seq: 3 +} + +auth { + mode: inherit +} diff --git a/TaskNoteBruno/User Session/999-Delete account.bru b/TaskNoteBruno/User Session/999-Delete account.bru new file mode 100644 index 0000000..fea4d40 --- /dev/null +++ b/TaskNoteBruno/User Session/999-Delete account.bru @@ -0,0 +1,83 @@ +meta { + name: 999-Delete account + type: http + seq: 2 +} + +delete { + url: {{addr}}/rest/user-sessions/delete-account + body: none + auth: none +} + +headers { + Authorization: Bearer {{authToken}} +} + +tests { + test("Status code is 200", function() { + expect(res.getStatus()).to.equal(200); + }); + + test("Response time is acceptable", function() { + expect(res.getResponseTime()).to.be.below(3000); + }); + + test("User deletion response is valid", function() { + const body = res.getBody(); + + // User ID assertions + expect(body.userId).to.exist; + expect(body.userId).to.be.a('number'); + expect(body.userId).to.be.greaterThan(0); + + // Name should be null after deletion + expect(body.name).to.be.null; + + // Email assertions + expect(body.email).to.exist; + expect(body.email).to.be.a('string'); + expect(body.email).to.not.be.empty; + expect(body.email).to.match(/^[\w\.-]+@[\w\.-]+\.\w+$/); + + // Admin flag + expect(body.admin).to.exist; + expect(body.admin).to.be.a('boolean'); + + // CreatedAt assertions + expect(body.createdAt).to.exist; + expect(body.createdAt).to.be.a('string'); + expect(body.createdAt).to.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/); + + // InactivatedAt should exist and not be null (user was deleted) + expect(body.inactivatedAt).to.exist; + expect(body.inactivatedAt).to.not.be.null; + expect(body.inactivatedAt).to.be.a('string'); + expect(body.inactivatedAt).to.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/); + + // Gravatar URL + expect(body.gravatarImageUrl).to.exist; + expect(body.gravatarImageUrl).to.be.a('string'); + expect(body.gravatarImageUrl).to.have.lengthOf(64); // SHA-256 hash length + }); + + test("User was inactivated after creation", function() { + const body = res.getBody(); + + const createdAt = new Date(body.createdAt); + const inactivatedAt = new Date(body.inactivatedAt); + + expect(inactivatedAt).to.be.greaterThan(createdAt); + }); + + test("Email matches the test user", function() { + const body = res.getBody(); + const expectedEmail = bru.getVar("testEmail"); + + expect(body.email).to.equal(expectedEmail); + }); +} + +settings { + encodeUrl: true +} diff --git a/TaskNoteBruno/User Session/folder.bru b/TaskNoteBruno/User Session/folder.bru new file mode 100644 index 0000000..cb9e17c --- /dev/null +++ b/TaskNoteBruno/User Session/folder.bru @@ -0,0 +1,8 @@ +meta { + name: User Session + seq: 5 +} + +auth { + mode: inherit +} diff --git a/TaskNoteBruno/bruno.json b/TaskNoteBruno/bruno.json new file mode 100644 index 0000000..0070534 --- /dev/null +++ b/TaskNoteBruno/bruno.json @@ -0,0 +1,9 @@ +{ + "version": "1", + "name": "TaskNoteBruno", + "type": "collection", + "ignore": [ + "node_modules", + ".git" + ] +} \ No newline at end of file diff --git a/TaskNoteBruno/collection.bru b/TaskNoteBruno/collection.bru new file mode 100644 index 0000000..5184b85 --- /dev/null +++ b/TaskNoteBruno/collection.bru @@ -0,0 +1,11 @@ +auth { + mode: bearer +} + +auth:bearer { + token: eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJKYXZhLUFQSSIsInN1YiI6InJpY2FyZG9tcGNhbXBvc0BnbWFpbC5jb20iLCJpYXQiOjE3NTgzOTQ5NzEsImV4cCI6MTc1ODk5OTc3MSwicm9sZXMiOltdLCJ1c2VySWQiOjEsImVtYWlsIjoicmljYXJkb21wY2FtcG9zQGdtYWlsLmNvbSJ9.ZdlouCYWF_kIEwJ2d7Nl3ASA6xS9OeSke84KXa94ugo +} + +vars:pre-request { + addr: http://localhost:8585 +} diff --git a/TaskNoteBruno/environments/dev.bru b/TaskNoteBruno/environments/dev.bru new file mode 100644 index 0000000..1ead617 --- /dev/null +++ b/TaskNoteBruno/environments/dev.bru @@ -0,0 +1,3 @@ +vars { + addr: http://localhost:8585 +} diff --git a/TaskNoteBruno/environments/prod.bru b/TaskNoteBruno/environments/prod.bru new file mode 100644 index 0000000..79c8c72 --- /dev/null +++ b/TaskNoteBruno/environments/prod.bru @@ -0,0 +1,3 @@ +vars { + addr: https://api.tasknoteapp.dev.br +} diff --git a/TaskNoteBruno/environments/stage.bru b/TaskNoteBruno/environments/stage.bru new file mode 100644 index 0000000..7702d1b --- /dev/null +++ b/TaskNoteBruno/environments/stage.bru @@ -0,0 +1,3 @@ +vars { + addr: https://stageapi.tasknoteapp.dev.br +} diff --git a/TaskNoteBruno/results.html b/TaskNoteBruno/results.html new file mode 100644 index 0000000..f32d144 --- /dev/null +++ b/TaskNoteBruno/results.html @@ -0,0 +1,795 @@ + + +
+ + + + + +