@@ -10,22 +10,72 @@ describe('public API', () => {
10
10
it ( 'should return ajax response on ajax request' , done => {
11
11
reconfigureServer ( {
12
12
publicServerURL : 'http://localhost:8378/1' ,
13
- } ) . then ( ( ) => {
14
- return req ( {
15
- method : 'POST' ,
16
- url : 'http://localhost:8378/1/apps/test/request_password_reset' ,
17
- body : `new_password=user1&token=43634643&username=` ,
18
- headers : {
19
- 'Content-Type' : 'application/x-www-form-urlencoded' ,
20
- 'X-Requested-With' : 'XMLHttpRequest'
21
- } ,
22
- followRedirects : false ,
13
+ } )
14
+ . then ( ( ) => {
15
+ return req ( {
16
+ method : 'POST' ,
17
+ url : 'http://localhost:8378/1/apps/test/request_password_reset' ,
18
+ body : `new_password=user1&token=43634643&username=` ,
19
+ headers : {
20
+ 'Content-Type' : 'application/x-www-form-urlencoded' ,
21
+ 'X-Requested-With' : 'XMLHttpRequest' ,
22
+ } ,
23
+ followRedirects : false ,
24
+ } ) ;
25
+ } )
26
+ . catch ( error => {
27
+ expect ( error . status ) . not . toBe ( 302 ) ;
28
+ expect ( error . text ) . toEqual ( '{"code":200,"error":"Missing username"}' ) ;
29
+ done ( ) ;
30
+ } ) ;
31
+ } ) ;
32
+
33
+ it ( 'should return missing token error on ajax request without token provided' , done => {
34
+ reconfigureServer ( {
35
+ publicServerURL : 'http://localhost:8378/1' ,
36
+ } )
37
+ . then ( ( ) => {
38
+ return req ( {
39
+ method : 'POST' ,
40
+ url : 'http://localhost:8378/1/apps/test/request_password_reset' ,
41
+ body : `new_password=user1&token=&username=Johnny` ,
42
+ headers : {
43
+ 'Content-Type' : 'application/x-www-form-urlencoded' ,
44
+ 'X-Requested-With' : 'XMLHttpRequest' ,
45
+ } ,
46
+ followRedirects : false ,
47
+ } ) ;
23
48
} )
24
- } ) . catch ( error => {
25
- expect ( error . status ) . not . toBe ( 302 ) ;
26
- expect ( error . text ) . toEqual ( '{"code":200,"error":"Missing username"}' ) ;
27
- done ( )
49
+ . catch ( error => {
50
+ console . log ( 'ERROR IN TEST: ' , error ) ;
51
+ expect ( error . status ) . not . toBe ( 302 ) ;
52
+ expect ( error . text ) . toEqual ( '{"code":-1,"error":"Missing token"}' ) ;
53
+ done ( ) ;
54
+ } ) ;
55
+ } ) ;
56
+
57
+ it ( 'should return missing password error on ajax request without password provided' , done => {
58
+ reconfigureServer ( {
59
+ publicServerURL : 'http://localhost:8378/1' ,
28
60
} )
61
+ . then ( ( ) => {
62
+ return req ( {
63
+ method : 'POST' ,
64
+ url : 'http://localhost:8378/1/apps/test/request_password_reset' ,
65
+ body : `new_password=&token=132414&username=Johnny` ,
66
+ headers : {
67
+ 'Content-Type' : 'application/x-www-form-urlencoded' ,
68
+ 'X-Requested-With' : 'XMLHttpRequest' ,
69
+ } ,
70
+ followRedirects : false ,
71
+ } ) ;
72
+ } )
73
+ . catch ( error => {
74
+ console . log ( 'ERROR IN TEST: ' , error ) ;
75
+ expect ( error . status ) . not . toBe ( 302 ) ;
76
+ expect ( error . text ) . toEqual ( '{"code":201,"error":"Missing password"}' ) ;
77
+ done ( ) ;
78
+ } ) ;
29
79
} ) ;
30
80
31
81
it ( 'should get invalid_link.html' , done => {
0 commit comments