@@ -9,6 +9,9 @@ var userMemory = loopback.createDataSource({
9
9
10
10
describe ( 'User' , function ( ) {
11
11
var validCredentials = { email :
'[email protected] ' , password :
'bar' } ;
12
+ var invalidCredentials = { email :
'[email protected] ' , password :
'bar1' } ;
13
+ var incompleteCredentials = { password : 'bar1' } ;
14
+
12
15
beforeEach ( function ( ) {
13
16
User = loopback . User . extend ( 'user' ) ;
14
17
User . email = loopback . Email . extend ( 'email' ) ;
@@ -135,6 +138,40 @@ describe('User', function(){
135
138
} ) ;
136
139
} ) ;
137
140
141
+ it ( 'Login a user over REST by providing invalid credentials' , function ( done ) {
142
+ request ( app )
143
+ . post ( '/users/login' )
144
+ . expect ( 'Content-Type' , / j s o n / )
145
+ . expect ( 401 )
146
+ . send ( invalidCredentials )
147
+ . end ( function ( err , res ) {
148
+ done ( ) ;
149
+ } ) ;
150
+ } ) ;
151
+
152
+ it ( 'Login a user over REST by providing incomplete credentials' , function ( done ) {
153
+ request ( app )
154
+ . post ( '/users/login' )
155
+ . expect ( 'Content-Type' , / j s o n / )
156
+ . expect ( 400 )
157
+ . send ( incompleteCredentials )
158
+ . end ( function ( err , res ) {
159
+ done ( ) ;
160
+ } ) ;
161
+ } ) ;
162
+
163
+ it ( 'Login a user over REST with the wrong Content-Type' , function ( done ) {
164
+ request ( app )
165
+ . post ( '/users/login' )
166
+ . set ( 'Content-Type' , null )
167
+ . expect ( 'Content-Type' , / j s o n / )
168
+ . expect ( 400 )
169
+ . send ( validCredentials )
170
+ . end ( function ( err , res ) {
171
+ done ( ) ;
172
+ } ) ;
173
+ } ) ;
174
+
138
175
it ( 'Returns current user when `include` is `USER`' , function ( done ) {
139
176
request ( app )
140
177
. post ( '/users/login?include=USER' )
0 commit comments