@@ -52,6 +52,27 @@ describe('auth', async () => {
52
52
res . should . have . status ( 200 ) ;
53
53
} ) ;
54
54
55
+ it ( 'should be able to set the git account' , async function ( ) {
56
+ console . log ( `cookie: ${ cookie } ` ) ;
57
+ const res = await chai . request ( app ) . post ( '/api/auth/gitAccount' )
58
+ . set ( 'Cookie' , `${ cookie } ` )
59
+ . send ( {
60
+ username : 'admin' ,
61
+ gitAccount : 'new-account' ,
62
+ } ) ;
63
+ res . should . have . status ( 200 ) ;
64
+ } ) ;
65
+
66
+ it ( 'should throw an error if the username is not provided when setting the git account' , async function ( ) {
67
+ const res = await chai . request ( app ) . post ( '/api/auth/gitAccount' )
68
+ . set ( 'Cookie' , `${ cookie } ` )
69
+ . send ( {
70
+ gitAccount : 'new-account' ,
71
+ } ) ;
72
+ console . log ( `res: ${ JSON . stringify ( res ) } ` ) ;
73
+ res . should . have . status ( 400 ) ;
74
+ } ) ;
75
+
55
76
it ( 'should now be able to logout' , async function ( ) {
56
77
const res = await chai . request ( app ) . post ( '/api/auth/logout' ) . set ( 'Cookie' , `${ cookie } ` ) ;
57
78
res . should . have . status ( 200 ) ;
@@ -78,6 +99,19 @@ describe('auth', async () => {
78
99
} ) ;
79
100
res . should . have . status ( 401 ) ;
80
101
} ) ;
102
+
103
+ it ( 'should fail to set the git account if the user is not logged in' , async function ( ) {
104
+ const res = await chai . request ( app ) . post ( '/api/auth/gitAccount' ) . send ( {
105
+ username : 'admin' ,
106
+ gitAccount : 'new-account' ,
107
+ } ) ;
108
+ res . should . have . status ( 401 ) ;
109
+ } ) ;
110
+
111
+ it ( 'should fail to get the current user metadata if not logged in' , async function ( ) {
112
+ const res = await chai . request ( app ) . get ( '/api/auth/me' ) ;
113
+ res . should . have . status ( 401 ) ;
114
+ } ) ;
81
115
} ) ;
82
116
83
117
after ( async function ( ) {
0 commit comments