@@ -16,7 +16,7 @@ const expect = chai.expect;
16
16
chai . use ( chaiHttp ) ;
17
17
18
18
19
- describe ( 'Auth endpoints ' , function ( ) {
19
+ describe ( 'Protected endpoint ' , function ( ) {
20
20
const username = 'exampleUser' ;
21
21
const password = 'examplePass' ;
22
22
const firstName = 'Example' ;
@@ -45,10 +45,10 @@ describe('Auth endpoints', function() {
45
45
return User . remove ( { } ) ;
46
46
} ) ;
47
47
48
- describe ( '/api/secret ' , function ( ) {
48
+ describe ( '/api/protected ' , function ( ) {
49
49
it ( 'Should reject requests with no credentials' , function ( ) {
50
50
return chai . request ( app )
51
- . get ( '/api/secret ' )
51
+ . get ( '/api/protected ' )
52
52
. then ( ( ) => expect . fail ( null , null , 'Request should not succeed' ) )
53
53
. catch ( err => {
54
54
if ( err instanceof chai . AssertionError ) {
@@ -71,7 +71,7 @@ describe('Auth endpoints', function() {
71
71
} ) ;
72
72
73
73
return chai . request ( app )
74
- . get ( '/api/secret ' )
74
+ . get ( '/api/protected ' )
75
75
. set ( 'Authorization' , `Bearer ${ token } ` )
76
76
. then ( ( ) => expect . fail ( null , null , 'Request should not succeed' ) )
77
77
. catch ( err => {
@@ -97,7 +97,7 @@ describe('Auth endpoints', function() {
97
97
} ) ;
98
98
99
99
return chai . request ( app )
100
- . get ( '/api/secret ' )
100
+ . get ( '/api/protected ' )
101
101
. set ( 'authorization' , `Bearer ${ token } ` )
102
102
. then ( ( ) => expect . fail ( null , null , 'Request should not succeed' ) )
103
103
. catch ( err => {
@@ -109,7 +109,7 @@ describe('Auth endpoints', function() {
109
109
expect ( res ) . to . have . status ( 401 ) ;
110
110
} ) ;
111
111
} ) ;
112
- it ( 'Should send a secret ' , function ( ) {
112
+ it ( 'Should send protected data ' , function ( ) {
113
113
const token = jwt . sign ( {
114
114
user : {
115
115
username,
@@ -123,12 +123,12 @@ describe('Auth endpoints', function() {
123
123
} ) ;
124
124
125
125
return chai . request ( app )
126
- . get ( '/api/secret ' )
126
+ . get ( '/api/protected ' )
127
127
. set ( 'authorization' , `Bearer ${ token } ` )
128
128
. then ( res => {
129
129
expect ( res ) . to . have . status ( 200 ) ;
130
130
expect ( res . body ) . to . be . an ( 'object' ) ;
131
- expect ( res . body . secret ) . to . equal ( 'rosebud' ) ;
131
+ expect ( res . body . data ) . to . equal ( 'rosebud' ) ;
132
132
} ) ;
133
133
} ) ;
134
134
} ) ;
0 commit comments