@@ -35,9 +35,9 @@ const store = {
3535} ;
3636
3737const sandbox = chai . spy . sandbox ( ) ;
38- describe ( 'OAuth' , async ( ) => {
38+ describe ( 'OAuth' , async function ( ) {
3939 before ( ( done ) => {
40- ( async ( ) => {
40+ ( async function ( ) {
4141 this . _server = new Armadietto ( {
4242 store,
4343 http : { port : 4567 } ,
@@ -49,13 +49,13 @@ describe('OAuth', async () => {
4949 } ) ;
5050
5151 after ( ( done ) => {
52- ( async ( ) => {
52+ ( async function ( ) {
5353 await this . _server . stop ( ) ;
5454 done ( ) ;
5555 } ) ( ) ;
5656 } ) ;
5757
58- beforeEach ( ( ) => {
58+ beforeEach ( function ( ) {
5959 this . auth_params = {
6060 username : 'zebcoe' ,
6161 password : 'locog' ,
@@ -69,93 +69,94 @@ describe('OAuth', async () => {
6969 sandbox . on ( store , [ 'authorize' , 'authenticate' ] ) ;
7070 } ) ;
7171
72- afterEach ( ( ) => {
72+ afterEach ( function ( ) {
7373 sandbox . restore ( ) ;
7474 } ) ;
7575
76- describe ( 'with invalid client input' , ( ) => {
77- beforeEach ( ( ) => {
78- delete this . auth_params . state ;
76+ describe ( 'with invalid client input' , function ( ) {
77+ beforeEach ( function ( ) {
78+ delete this . auth_params ?. state ;
79+ this . timeout ( 60_000 ) ;
7980 } ) ;
8081
81- it ( 'returns an error if redirect_uri is missing' , async ( ) => {
82+ it ( 'returns an error if redirect_uri is missing' , async function ( ) {
8283 delete this . auth_params . redirect_uri ;
8384 const res = await get ( '/oauth/me' , this . auth_params ) ;
8485 expect ( res ) . to . have . status ( 400 ) ;
8586 expect ( res . text ) . to . have . been . equal ( 'error=invalid_request&error_description=Required%20parameter%20%22redirect_uri%22%20is%20missing' ) ;
8687 } ) ;
8788
88- it ( 'returns an error if client_id is missing' , async ( ) => {
89+ it ( 'returns an error if client_id is missing' , async function ( ) {
8990 delete this . auth_params . client_id ;
9091 const res = await get ( '/oauth/me' , this . auth_params ) ;
9192 expect ( res ) . to . redirectTo ( 'http://example.com/cb#error=invalid_request&error_description=Required%20parameter%20%22client_id%22%20is%20missing' ) ;
9293 } ) ;
9394
94- it ( 'returns an error if response_type is missing' , async ( ) => {
95+ it ( 'returns an error if response_type is missing' , async function ( ) {
9596 delete this . auth_params . response_type ;
9697 const res = await get ( '/oauth/me' , this . auth_params ) ;
9798 expect ( res ) . to . redirectTo ( 'http://example.com/cb#error=invalid_request&error_description=Required%20parameter%20%22response_type%22%20is%20missing' ) ;
9899 } ) ;
99100
100- it ( 'returns an error if response_type is not recognized' , async ( ) => {
101+ it ( 'returns an error if response_type is not recognized' , async function ( ) {
101102 this . auth_params . response_type = 'wrong' ;
102103 const res = await get ( '/oauth/me' , this . auth_params ) ;
103104 expect ( res ) . to . redirectTo ( 'http://example.com/cb#error=unsupported_response_type&error_description=Response%20type%20%22wrong%22%20is%20not%20supported' ) ;
104105 } ) ;
105106
106- it ( 'returns an error if scope is missing' , async ( ) => {
107+ it ( 'returns an error if scope is missing' , async function ( ) {
107108 delete this . auth_params . scope ;
108109 const res = await get ( '/oauth/me' , this . auth_params ) ;
109110 expect ( res ) . to . redirectTo ( 'http://example.com/cb#error=invalid_scope&error_description=Parameter%20%22scope%22%20is%20invalid' ) ;
110111 } ) ;
111112
112- it ( 'returns an error if username is missing' , async ( ) => {
113+ it ( 'returns an error if username is missing' , async function ( ) {
113114 delete this . auth_params . username ;
114115 const res = await post ( '/oauth' , this . auth_params ) ;
115116 expect ( res ) . to . have . status ( 400 ) ;
116117 } ) ;
117118 } ) ;
118119
119- describe ( 'with valid login credentials' , async ( ) => {
120- describe ( 'without explicit read/write permissions' , async ( ) => {
121- it ( 'authorizes the client to read and write' , async ( ) => {
120+ describe ( 'with valid login credentials' , async function ( ) {
121+ describe ( 'without explicit read/write permissions' , async function ( ) {
122+ it ( 'authorizes the client to read and write' , async function ( ) {
122123 await post ( '/oauth' , this . auth_params ) ;
123124 expect ( store . authorize ) . to . be . called . with ( 'the_client_id' , 'zebcoe' , { the_scope : [ 'r' , 'w' ] } ) ;
124125 } ) ;
125126 } ) ;
126127
127- describe ( 'with explicit read permission' , async ( ) => {
128- it ( 'authorizes the client to read' , async ( ) => {
128+ describe ( 'with explicit read permission' , async function ( ) {
129+ it ( 'authorizes the client to read' , async function ( ) {
129130 this . auth_params . scope = 'the_scope:r' ;
130131 await post ( '/oauth' , this . auth_params ) ;
131132 expect ( store . authorize ) . to . be . called . with ( 'the_client_id' , 'zebcoe' , { the_scope : [ 'r' ] } ) ;
132133 } ) ;
133134 } ) ;
134135
135- describe ( 'with explicit read/write permission' , async ( ) => {
136- it ( 'authorizes the client to read and write' , async ( ) => {
136+ describe ( 'with explicit read/write permission' , async function ( ) {
137+ it ( 'authorizes the client to read and write' , async function ( ) {
137138 this . auth_params . scope = 'the_scope:rw' ;
138139 await post ( '/oauth' , this . auth_params ) ;
139140 expect ( store . authorize ) . to . be . called . with ( 'the_client_id' , 'zebcoe' , { the_scope : [ 'r' , 'w' ] } ) ;
140141 } ) ;
141142 } ) ;
142143
143- it ( 'redirects with an access token' , async ( ) => {
144+ it ( 'redirects with an access token' , async function ( ) {
144145 const res = await post ( '/oauth' , this . auth_params ) ;
145146 expect ( res ) . to . redirectTo ( 'http://example.com/cb#access_token=a_token&token_type=bearer&state=the_state' ) ;
146147 } ) ;
147148 } ) ;
148149
149- describe ( 'with invalid login credentials' , async ( ) => {
150- it ( 'does not authorize the client' , async ( ) => {
150+ describe ( 'with invalid login credentials' , async function ( ) {
151+ it ( 'does not authorize the client' , async function ( ) {
151152 store . authenticate = ( params ) => {
152153 throw new Error ( ) ;
153154 } ;
154155 await post ( '/oauth' , this . auth_params ) ;
155156 expect ( store . authorize ) . to . be . called . exactly ( 0 ) ;
156157 } ) ;
157158
158- it ( 'returns a 401 response with the login form' , async ( ) => {
159+ it ( 'returns a 401 response with the login form' , async function ( ) {
159160 store . authenticate = ( params ) => {
160161 throw new Error ( ) ;
161162 } ;
0 commit comments