@@ -52,6 +52,27 @@ describe('auth', async () => {
5252 res . should . have . status ( 200 ) ;
5353 } ) ;
5454
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+
5576 it ( 'should now be able to logout' , async function ( ) {
5677 const res = await chai . request ( app ) . post ( '/api/auth/logout' ) . set ( 'Cookie' , `${ cookie } ` ) ;
5778 res . should . have . status ( 200 ) ;
@@ -78,6 +99,19 @@ describe('auth', async () => {
7899 } ) ;
79100 res . should . have . status ( 401 ) ;
80101 } ) ;
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+ } ) ;
81115 } ) ;
82116
83117 after ( async function ( ) {
0 commit comments