feat: add Bruno Collections
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
meta {
|
||||
name: Authentication
|
||||
seq: 2
|
||||
}
|
||||
|
||||
auth {
|
||||
mode: inherit
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
meta {
|
||||
name: Home
|
||||
seq: 4
|
||||
}
|
||||
|
||||
auth {
|
||||
mode: inherit
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
meta {
|
||||
name: Session
|
||||
seq: 2
|
||||
}
|
||||
|
||||
auth {
|
||||
mode: inherit
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
meta {
|
||||
name: Task
|
||||
seq: 3
|
||||
}
|
||||
|
||||
auth {
|
||||
mode: inherit
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
meta {
|
||||
name: User Session
|
||||
seq: 5
|
||||
}
|
||||
|
||||
auth {
|
||||
mode: inherit
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"version": "1",
|
||||
"name": "TaskNoteBruno",
|
||||
"type": "collection",
|
||||
"ignore": [
|
||||
"node_modules",
|
||||
".git"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
auth {
|
||||
mode: bearer
|
||||
}
|
||||
|
||||
auth:bearer {
|
||||
token: eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJKYXZhLUFQSSIsInN1YiI6InJpY2FyZG9tcGNhbXBvc0BnbWFpbC5jb20iLCJpYXQiOjE3NTgzOTQ5NzEsImV4cCI6MTc1ODk5OTc3MSwicm9sZXMiOltdLCJ1c2VySWQiOjEsImVtYWlsIjoicmljYXJkb21wY2FtcG9zQGdtYWlsLmNvbSJ9.ZdlouCYWF_kIEwJ2d7Nl3ASA6xS9OeSke84KXa94ugo
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
addr: http://localhost:8585
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
vars {
|
||||
addr: http://localhost:8585
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
vars {
|
||||
addr: https://api.tasknoteapp.dev.br
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
vars {
|
||||
addr: https://stageapi.tasknoteapp.dev.br
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user