@@ -19,26 +19,28 @@ async fn create_token_logged_out() {
19
19
20
20
#[ tokio:: test( flavor = "multi_thread" ) ]
21
21
async fn create_token_invalid_request ( ) {
22
- let ( _ , _, user) = TestApp :: init ( ) . with_user ( ) ;
22
+ let ( app , _, user) = TestApp :: init ( ) . with_user ( ) ;
23
23
let invalid: & [ u8 ] = br#"{ "name": "" }"# ;
24
24
let response = user. put :: < ( ) > ( "/api/v1/me/tokens" , invalid) . await ;
25
25
assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
26
26
assert_eq ! (
27
27
response. json( ) ,
28
28
json!( { "errors" : [ { "detail" : "invalid new token request: Error(\" missing field `api_token`\" , line: 1, column: 14)" } ] } )
29
29
) ;
30
+ assert ! ( app. as_inner( ) . emails. mails_in_memory( ) . unwrap( ) . is_empty( ) ) ;
30
31
}
31
32
32
33
#[ tokio:: test( flavor = "multi_thread" ) ]
33
34
async fn create_token_no_name ( ) {
34
- let ( _ , _, user) = TestApp :: init ( ) . with_user ( ) ;
35
+ let ( app , _, user) = TestApp :: init ( ) . with_user ( ) ;
35
36
let empty_name: & [ u8 ] = br#"{ "api_token": { "name": "" } }"# ;
36
37
let response = user. put :: < ( ) > ( "/api/v1/me/tokens" , empty_name) . await ;
37
38
assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
38
39
assert_eq ! (
39
40
response. json( ) ,
40
41
json!( { "errors" : [ { "detail" : "name must have a value" } ] } )
41
42
) ;
43
+ assert ! ( app. as_inner( ) . emails. mails_in_memory( ) . unwrap( ) . is_empty( ) ) ;
42
44
}
43
45
44
46
#[ tokio:: test( flavor = "multi_thread" ) ]
@@ -56,6 +58,7 @@ async fn create_token_exceeded_tokens_per_user() {
56
58
response. json( ) ,
57
59
json!( { "errors" : [ { "detail" : "maximum tokens per user is: 500" } ] } )
58
60
) ;
61
+ assert ! ( app. as_inner( ) . emails. mails_in_memory( ) . unwrap( ) . is_empty( ) ) ;
59
62
}
60
63
61
64
#[ tokio:: test( flavor = "multi_thread" ) ]
@@ -82,6 +85,7 @@ async fn create_token_success() {
82
85
assert_eq ! ( tokens[ 0 ] . last_used_at, None ) ;
83
86
assert_eq ! ( tokens[ 0 ] . crate_scopes, None ) ;
84
87
assert_eq ! ( tokens[ 0 ] . endpoint_scopes, None ) ;
88
+ assert_eq ! ( app. as_inner( ) . emails. mails_in_memory( ) . unwrap( ) . len( ) , 1 ) ;
85
89
}
86
90
87
91
#[ tokio:: test( flavor = "multi_thread" ) ]
@@ -107,7 +111,7 @@ async fn create_token_multiple_users_have_different_values() {
107
111
108
112
#[ tokio:: test( flavor = "multi_thread" ) ]
109
113
async fn cannot_create_token_with_token ( ) {
110
- let ( _ , _, _, token) = TestApp :: init ( ) . with_token ( ) ;
114
+ let ( app , _, _, token) = TestApp :: init ( ) . with_token ( ) ;
111
115
let response = token
112
116
. put :: < ( ) > (
113
117
"/api/v1/me/tokens" ,
@@ -119,6 +123,7 @@ async fn cannot_create_token_with_token() {
119
123
response. json( ) ,
120
124
json!( { "errors" : [ { "detail" : "cannot use an API token to create a new API token" } ] } )
121
125
) ;
126
+ assert ! ( app. as_inner( ) . emails. mails_in_memory( ) . unwrap( ) . is_empty( ) ) ;
122
127
}
123
128
124
129
#[ tokio:: test( flavor = "multi_thread" ) ]
@@ -164,6 +169,7 @@ async fn create_token_with_scopes() {
164
169
tokens[ 0 ] . endpoint_scopes,
165
170
Some ( vec![ EndpointScope :: PublishUpdate ] )
166
171
) ;
172
+ assert_eq ! ( app. as_inner( ) . emails. mails_in_memory( ) . unwrap( ) . len( ) , 1 ) ;
167
173
}
168
174
169
175
#[ tokio:: test( flavor = "multi_thread" ) ]
@@ -200,11 +206,12 @@ async fn create_token_with_null_scopes() {
200
206
assert_eq ! ( tokens[ 0 ] . last_used_at, None ) ;
201
207
assert_eq ! ( tokens[ 0 ] . crate_scopes, None ) ;
202
208
assert_eq ! ( tokens[ 0 ] . endpoint_scopes, None ) ;
209
+ assert_eq ! ( app. as_inner( ) . emails. mails_in_memory( ) . unwrap( ) . len( ) , 1 ) ;
203
210
}
204
211
205
212
#[ tokio:: test( flavor = "multi_thread" ) ]
206
213
async fn create_token_with_empty_crate_scope ( ) {
207
- let ( _ , _, user) = TestApp :: init ( ) . with_user ( ) ;
214
+ let ( app , _, user) = TestApp :: init ( ) . with_user ( ) ;
208
215
209
216
let json = json ! ( {
210
217
"api_token" : {
@@ -222,11 +229,12 @@ async fn create_token_with_empty_crate_scope() {
222
229
response. json( ) ,
223
230
json!( { "errors" : [ { "detail" : "invalid crate scope" } ] } )
224
231
) ;
232
+ assert ! ( app. as_inner( ) . emails. mails_in_memory( ) . unwrap( ) . is_empty( ) ) ;
225
233
}
226
234
227
235
#[ tokio:: test( flavor = "multi_thread" ) ]
228
236
async fn create_token_with_invalid_endpoint_scope ( ) {
229
- let ( _ , _, user) = TestApp :: init ( ) . with_user ( ) ;
237
+ let ( app , _, user) = TestApp :: init ( ) . with_user ( ) ;
230
238
231
239
let json = json ! ( {
232
240
"api_token" : {
@@ -244,11 +252,12 @@ async fn create_token_with_invalid_endpoint_scope() {
244
252
response. json( ) ,
245
253
json!( { "errors" : [ { "detail" : "invalid endpoint scope" } ] } )
246
254
) ;
255
+ assert ! ( app. as_inner( ) . emails. mails_in_memory( ) . unwrap( ) . is_empty( ) ) ;
247
256
}
248
257
249
258
#[ tokio:: test( flavor = "multi_thread" ) ]
250
259
async fn create_token_with_expiry_date ( ) {
251
- let ( _app , _, user) = TestApp :: init ( ) . with_user ( ) ;
260
+ let ( app , _, user) = TestApp :: init ( ) . with_user ( ) ;
252
261
253
262
let json = json ! ( {
254
263
"api_token" : {
@@ -269,4 +278,5 @@ async fn create_token_with_expiry_date() {
269
278
".api_token.last_used_at" => "[datetime]" ,
270
279
".api_token.token" => insta:: api_token_redaction( ) ,
271
280
} ) ;
281
+ assert_eq ! ( app. as_inner( ) . emails. mails_in_memory( ) . unwrap( ) . len( ) , 1 ) ;
272
282
}
0 commit comments