Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
simcaq-node
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
simcaq
simcaq-node
Commits
6da004e7
There was a problem fetching the pipeline summary.
Commit
6da004e7
authored
8 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Add more user tests
parent
23927270
No related branches found
No related tags found
2 merge requests
!116
Release v1.0.0
,
!27
Implement UC201 - Select Location
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/user.js
+469
-71
469 additions, 71 deletions
src/test/user.js
with
469 additions
and
71 deletions
src/test/user.js
+
469
−
71
View file @
6da004e7
...
...
@@ -27,6 +27,367 @@ const mongoose = require('../libs/db/mongoose');
const
User
=
require
(
'
../libs/models/user
'
);
chai
.
use
(
chaiHttp
);
describe
(
'
Saves a user
'
,
()
=>
{
beforeEach
(()
=>
{
User
.
remove
({},
(
err
)
=>
{
console
.
log
(
'
Test collection purged
'
)
});
});
it
(
'
should save a user
'
,
(
done
)
=>
{
let
newUser
=
{};
newUser
.
email
=
'
lorem@ipsum.com
'
;
newUser
.
password
=
'
123mudar
'
;
newUser
.
name
=
'
Gute
'
;
newUser
.
cpf
=
'
08236017907
'
;
newUser
.
schooling
=
'
Doutorado
'
;
newUser
.
course
=
'
Ciência da Computação
'
;
newUser
.
segment
=
'
Comunidade acadêmica
'
;
newUser
.
role
=
'
Pesquisador
'
;
newUser
.
institution_name
=
'
UFPR
'
;
newUser
.
state
=
'
PR
'
;
newUser
.
city
=
'
Curitiba
'
;
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
(
newUser
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
true
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
be
.
equal
(
'
Usuário cadastrado com sucesso!
'
);
done
();
});
});
it
(
'
should not save a user without email
'
,
(
done
)
=>
{
let
newUser
=
{};
newUser
.
email
=
null
;
newUser
.
password
=
'
123mudar
'
;
newUser
.
name
=
'
Gute
'
;
newUser
.
cpf
=
'
08236017907
'
;
newUser
.
schooling
=
'
Doutorado
'
;
newUser
.
course
=
'
Ciência da Computação
'
;
newUser
.
segment
=
'
Comunidade acadêmica
'
;
newUser
.
role
=
'
Pesquisador
'
;
newUser
.
institution_name
=
'
UFPR
'
;
newUser
.
state
=
'
PR
'
;
newUser
.
city
=
'
Curitiba
'
;
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
(
newUser
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
be
.
equal
(
'
O campo Email é obrigatório.
'
);
done
();
});
});
it
(
'
should not save a user without password
'
,
(
done
)
=>
{
let
newUser
=
{};
newUser
.
email
=
'
lorem@ipsum.com
'
;
newUser
.
name
=
'
Gute
'
;
newUser
.
cpf
=
'
08236017907
'
;
newUser
.
schooling
=
'
Doutorado
'
;
newUser
.
course
=
'
Ciência da Computação
'
;
newUser
.
segment
=
'
Comunidade acadêmica
'
;
newUser
.
role
=
'
Pesquisador
'
;
newUser
.
institution_name
=
'
UFPR
'
;
newUser
.
state
=
'
PR
'
;
newUser
.
city
=
'
Curitiba
'
;
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
(
newUser
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
be
.
equal
(
'
O campo Senha é obrigatório.
'
);
done
();
});
});
it
(
'
should not save a user with invalid email
'
,
(
done
)
=>
{
let
newUser
=
{};
newUser
.
email
=
'
invalid email
'
;
newUser
.
password
=
'
123mudar
'
;
newUser
.
name
=
'
Gute
'
;
newUser
.
cpf
=
'
08236017907
'
;
newUser
.
schooling
=
'
Doutorado
'
;
newUser
.
course
=
'
Ciência da Computação
'
;
newUser
.
segment
=
'
Comunidade acadêmica
'
;
newUser
.
role
=
'
Pesquisador
'
;
newUser
.
institution_name
=
'
UFPR
'
;
newUser
.
state
=
'
PR
'
;
newUser
.
city
=
'
Curitiba
'
;
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
(
newUser
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
be
.
equal
(
'
O email informado é inválido.
'
);
done
();
});
});
it
(
'
should not save a user without a name
'
,
(
done
)
=>
{
let
newUser
=
{};
newUser
.
email
=
'
lorem@ipsum.com
'
;
newUser
.
password
=
'
123mudar
'
;
newUser
.
cpf
=
'
08236017907
'
;
newUser
.
schooling
=
'
Doutorado
'
;
newUser
.
course
=
'
Ciência da Computação
'
;
newUser
.
segment
=
'
Comunidade acadêmica
'
;
newUser
.
role
=
'
Pesquisador
'
;
newUser
.
institution_name
=
'
UFPR
'
;
newUser
.
state
=
'
PR
'
;
newUser
.
city
=
'
Curitiba
'
;
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
(
newUser
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
be
.
equal
(
'
O campo Nome é obrigatório.
'
);
done
();
});
});
it
(
'
should not save a user without CPF
'
,
(
done
)
=>
{
let
newUser
=
{};
newUser
.
email
=
'
lorem@ipsum.com
'
;
newUser
.
password
=
'
123mudar
'
;
newUser
.
name
=
'
Gute
'
;
newUser
.
schooling
=
'
Doutorado
'
;
newUser
.
course
=
'
Ciência da Computação
'
;
newUser
.
segment
=
'
Comunidade acadêmica
'
;
newUser
.
role
=
'
Pesquisador
'
;
newUser
.
institution_name
=
'
UFPR
'
;
newUser
.
state
=
'
PR
'
;
newUser
.
city
=
'
Curitiba
'
;
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
(
newUser
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
be
.
equal
(
'
O campo CPF é obrigatório.
'
);
done
();
});
});
it
(
'
should not save a user without schooling
'
,
(
done
)
=>
{
let
newUser
=
{};
newUser
.
email
=
'
lorem@ipsum.com
'
;
newUser
.
password
=
'
123mudar
'
;
newUser
.
name
=
'
Gute
'
;
newUser
.
cpf
=
'
08236017907
'
;
newUser
.
course
=
'
Ciência da Computação
'
;
newUser
.
segment
=
'
Comunidade acadêmica
'
;
newUser
.
role
=
'
Pesquisador
'
;
newUser
.
institution_name
=
'
UFPR
'
;
newUser
.
state
=
'
PR
'
;
newUser
.
city
=
'
Curitiba
'
;
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
(
newUser
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
be
.
equal
(
'
O campo Escolaridade é obrigatório.
'
);
done
();
});
});
it
(
'
should not save a user without segment
'
,
(
done
)
=>
{
let
newUser
=
{};
newUser
.
email
=
'
lorem@ipsum.com
'
;
newUser
.
password
=
'
123mudar
'
;
newUser
.
name
=
'
Gute
'
;
newUser
.
cpf
=
'
08236017907
'
;
newUser
.
schooling
=
'
Doutorado
'
;
newUser
.
course
=
'
Ciência da Computação
'
;
newUser
.
role
=
'
Pesquisador
'
;
newUser
.
institution_name
=
'
UFPR
'
;
newUser
.
state
=
'
PR
'
;
newUser
.
city
=
'
Curitiba
'
;
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
(
newUser
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
be
.
equal
(
'
O campo Segmento é obrigatório.
'
);
done
();
});
});
it
(
'
should not save a user without role
'
,
(
done
)
=>
{
let
newUser
=
{};
newUser
.
email
=
'
lorem@ipsum.com
'
;
newUser
.
password
=
'
123mudar
'
;
newUser
.
name
=
'
Gute
'
;
newUser
.
cpf
=
'
08236017907
'
;
newUser
.
schooling
=
'
Doutorado
'
;
newUser
.
course
=
'
Ciência da Computação
'
;
newUser
.
segment
=
'
Comunidade acadêmica
'
;
newUser
.
institution_name
=
'
UFPR
'
;
newUser
.
state
=
'
PR
'
;
newUser
.
city
=
'
Curitiba
'
;
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
(
newUser
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
be
.
equal
(
'
O campo Função é obrigatório.
'
);
done
();
});
});
it
(
'
should not save a user without institution_name
'
,
(
done
)
=>
{
let
newUser
=
{};
newUser
.
email
=
'
lorem@ipsum.com
'
;
newUser
.
password
=
'
123mudar
'
;
newUser
.
name
=
'
Gute
'
;
newUser
.
cpf
=
'
08236017907
'
;
newUser
.
schooling
=
'
Doutorado
'
;
newUser
.
course
=
'
Ciência da Computação
'
;
newUser
.
segment
=
'
Comunidade acadêmica
'
;
newUser
.
role
=
'
Pesquisador
'
;
newUser
.
state
=
'
PR
'
;
newUser
.
city
=
'
Curitiba
'
;
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
(
newUser
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
be
.
equal
(
'
O campo Instituição em que trabalha é obrigatório.
'
);
done
();
});
});
it
(
'
should not save a user without state
'
,
(
done
)
=>
{
let
newUser
=
{};
newUser
.
email
=
'
lorem@ipsum.com
'
;
newUser
.
password
=
'
123mudar
'
;
newUser
.
name
=
'
Gute
'
;
newUser
.
cpf
=
'
08236017907
'
;
newUser
.
schooling
=
'
Doutorado
'
;
newUser
.
course
=
'
Ciência da Computação
'
;
newUser
.
segment
=
'
Comunidade acadêmica
'
;
newUser
.
role
=
'
Pesquisador
'
;
newUser
.
institution_name
=
'
UFPR
'
;
newUser
.
city
=
'
Curitiba
'
;
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
(
newUser
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
be
.
equal
(
'
O campo Estado é obrigatório.
'
);
done
();
});
});
it
(
'
should not save a user without city
'
,
(
done
)
=>
{
let
newUser
=
{};
newUser
.
email
=
'
lorem@ipsum.com
'
;
newUser
.
password
=
'
123mudar
'
;
newUser
.
name
=
'
Gute
'
;
newUser
.
cpf
=
'
08236017907
'
;
newUser
.
schooling
=
'
Doutorado
'
;
newUser
.
course
=
'
Ciência da Computação
'
;
newUser
.
segment
=
'
Comunidade acadêmica
'
;
newUser
.
role
=
'
Pesquisador
'
;
newUser
.
institution_name
=
'
UFPR
'
;
newUser
.
state
=
'
Paraná
'
;
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
(
newUser
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
be
.
equal
(
'
O campo Cidade é obrigatório.
'
);
done
();
});
});
})
describe
(
'
Authenticates a user
'
,
()
=>
{
beforeEach
(()
=>
{
...
...
@@ -56,24 +417,24 @@ describe('Authenticates a user', () => {
}
}).
then
(
function
(
newuser
){
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/authenticate
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
({
email
:
'
lorem@ipsum.com
'
,
password
:
'
123mudar
'
})
.
end
((
err
,
res
)
=>
{
let
token
;
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
true
);
res
.
body
.
should
.
have
.
property
(
'
token
'
);
token
=
res
.
body
.
token
;
token
.
substr
(
0
,
3
).
should
.
equal
(
'
JWT
'
);
done
();
});
.
post
(
'
/api/v1/user/authenticate
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
({
email
:
'
lorem@ipsum.com
'
,
password
:
'
123mudar
'
})
.
end
((
err
,
res
)
=>
{
let
token
;
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
true
);
res
.
body
.
should
.
have
.
property
(
'
token
'
);
token
=
res
.
body
.
token
;
token
.
substr
(
0
,
3
).
should
.
equal
(
'
JWT
'
);
done
();
});
});
});
it
(
'
should not authenticate a user with wrong password
'
,
(
done
)
=>
{
...
...
@@ -97,21 +458,21 @@ describe('Authenticates a user', () => {
}
}).
then
(
function
(
newuser
){
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/authenticate
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
({
email
:
'
lorem@ipsum.com
'
,
password
:
'
umasenhaerrada
'
})
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
equal
(
'
A Senha informada é inválida.
'
)
done
();
});
.
post
(
'
/api/v1/user/authenticate
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
({
email
:
'
lorem@ipsum.com
'
,
password
:
'
umasenhaerrada
'
})
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
equal
(
'
A Senha informada é inválida.
'
)
done
();
});
});
});
it
(
'
should not authenticate a user with wrong email
'
,
(
done
)
=>
{
...
...
@@ -135,21 +496,21 @@ describe('Authenticates a user', () => {
}
}).
then
(
function
(
newuser
){
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/authenticate
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
({
email
:
'
dolor@ipsum.com
'
,
password
:
'
123mudar
'
})
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
equal
(
'
O Email informado não está cadastrado.
'
)
done
();
});
.
post
(
'
/api/v1/user/authenticate
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
({
email
:
'
dolor@ipsum.com
'
,
password
:
'
123mudar
'
})
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
equal
(
'
O Email informado não está cadastrado.
'
)
done
();
});
});
});
it
(
'
should not authenticate a user with missing email
'
,
(
done
)
=>
{
...
...
@@ -173,20 +534,20 @@ describe('Authenticates a user', () => {
}
}).
then
(
function
(
newuser
){
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/authenticate
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
({
password
:
'
123mudar
'
})
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
equal
(
'
O campo Email é obrigatório.
'
)
done
();
});
.
post
(
'
/api/v1/user/authenticate
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
({
password
:
'
123mudar
'
})
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
equal
(
'
O campo Email é obrigatório.
'
)
done
();
});
});
});
it
(
'
should not authenticate a user with missing password
'
,
(
done
)
=>
{
...
...
@@ -210,19 +571,56 @@ describe('Authenticates a user', () => {
}
}).
then
(
function
(
newuser
){
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/authenticate
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
({
email
:
'
lorem@ipsum.com
'
})
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
equal
(
'
O campo Senha é obrigatório.
'
)
done
();
});
.
post
(
'
/api/v1/user/authenticate
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
({
email
:
'
lorem@ipsum.com
'
})
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
equal
(
'
O campo Senha é obrigatório.
'
)
done
();
});
});
});
it
(
'
should not authenticate a user with wrong password
'
,
(
done
)
=>
{
let
newUser
=
new
User
();
newUser
.
email
=
'
lorem@ipsum.com
'
;
newUser
.
password
=
'
123mudar
'
;
newUser
.
name
=
'
Gute
'
;
newUser
.
cpf
=
'
08236017907
'
;
newUser
.
schooling
=
'
Doutorado
'
;
newUser
.
course
=
'
Ciência da Computação
'
;
newUser
.
segment
=
'
Comunidade acadêmica
'
;
newUser
.
role
=
'
Pesquisador
'
;
newUser
.
institution_name
=
'
UFPR
'
;
newUser
.
state
=
'
PR
'
;
newUser
.
city
=
'
Curitiba
'
;
newUser
.
save
((
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
MongoDB error:
'
+
err
);
}
}).
then
(
function
(
newuser
){
chai
.
request
(
server
)
.
post
(
'
/api/v1/user/authenticate
'
)
.
set
(
'
content-type
'
,
'
application/x-www-form-urlencoded
'
)
.
set
(
'
x-apicache-bypass
'
,
'
true
'
)
.
send
({
email
:
'
lorem@ipsum.com
'
,
password
:
'
123
'
})
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
res
.
body
.
should
.
have
.
property
(
'
msg
'
);
res
.
body
.
msg
.
should
.
equal
(
'
A Senha informada é inválida.
'
)
done
();
});
});
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment