@@ -90,6 +90,7 @@ class PortalTests: AppTestCase {
90
90
try withDependencies {
91
91
let mock : @Sendable ( _ req: Request , _ username: String , _ password: String ) async throws -> CognitoAuthenticateResponse = { _, _, _ in throw SotoCognitoError . unauthorized ( reason: " reason " ) }
92
92
$0. cognito. authenticate = mock
93
+ $0. environment. dbId = { nil }
93
94
} operation: {
94
95
try app. test ( . POST, " login " , beforeRequest: { req in try req. content. encode ( [ " email " : " testemail " , " password " : " testpassword " ] )
95
96
} , afterResponse: { res in
@@ -102,6 +103,7 @@ class PortalTests: AppTestCase {
102
103
try withDependencies {
103
104
let mock : @Sendable ( _ req: Request , _ username: String , _ password: String ) async throws -> CognitoAuthenticateResponse = { _, _, _ in throw AWSClientError . accessDenied }
104
105
$0. cognito. authenticate = mock
106
+ $0. environment. dbId = { nil }
105
107
} operation: {
106
108
try app. test ( . POST, " login " , beforeRequest: { req in try req. content. encode ( [ " email " : " testemail " , " password " : " testpassword " ] )
107
109
} , afterResponse: { res in
@@ -115,6 +117,7 @@ class PortalTests: AppTestCase {
115
117
try withDependencies {
116
118
let mock : @Sendable ( _ req: Request , _ username: String , _ password: String ) async throws -> CognitoAuthenticateResponse = { _, _, _ in throw SomeError ( ) }
117
119
$0. cognito. authenticate = mock
120
+ $0. environment. dbId = { nil }
118
121
} operation: {
119
122
try app. test ( . POST, " login " , beforeRequest: { req in try req. content. encode ( [ " email " : " testemail " , " password " : " testpassword " ] )
120
123
} , afterResponse: { res in
@@ -127,6 +130,7 @@ class PortalTests: AppTestCase {
127
130
try withDependencies {
128
131
let mock : @Sendable ( _ req: Request , _ username: String , _ password: String ) async throws -> Void = { _, _, _ in }
129
132
$0. cognito. signup = mock
133
+ $0. environment. dbId = { nil }
130
134
} operation: {
131
135
try app. test ( . POST, " signup " , beforeRequest: { req in try req. content. encode ( [ " email " : " testemail " , " password " : " testpassword " ] )
132
136
} , afterResponse: { res in
@@ -140,6 +144,7 @@ class PortalTests: AppTestCase {
140
144
try withDependencies {
141
145
let mock : @Sendable ( _ req: Request , _ username: String , _ password: String ) async throws -> Void = { _, _, _ in throw AWSClientError . accessDenied }
142
146
$0. cognito. signup = mock
147
+ $0. environment. dbId = { nil }
143
148
} operation: {
144
149
try app. test ( . POST, " signup " , beforeRequest: { req in try req. content. encode ( [ " email " : " testemail " , " password " : " testpassword " ] )
145
150
} , afterResponse: { res in
@@ -153,6 +158,7 @@ class PortalTests: AppTestCase {
153
158
try withDependencies {
154
159
let mock : @Sendable ( _ req: Request , _ username: String , _ password: String ) async throws -> Void = { _, _, _ in throw SomeError ( ) }
155
160
$0. cognito. signup = mock
161
+ $0. environment. dbId = { nil }
156
162
} operation: {
157
163
try app. test ( . POST, " signup " ) { res in
158
164
XCTAssertTrue ( res. body. string. contains ( " error " ) )
@@ -164,6 +170,7 @@ class PortalTests: AppTestCase {
164
170
try withDependencies {
165
171
let mock : @Sendable ( _ req: Request , _ username: String , _ password: String , _ confirmationCode: String ) async throws -> Void = { _, _, _, _ in }
166
172
$0. cognito. resetPassword = mock
173
+ $0. environment. dbId = { nil }
167
174
} operation: {
168
175
try app. test ( . POST, " reset " , beforeRequest: { req in try req. content. encode ( [ " email " : " testemail " , " password " : " testpassword " , " confirmationCode " : " 123 " ] )
169
176
} , afterResponse: { res in
@@ -177,6 +184,7 @@ class PortalTests: AppTestCase {
177
184
try withDependencies {
178
185
let mock : @Sendable ( _ req: Request , _ username: String , _ password: String , _ confirmationCode: String ) async throws -> Void = { _, _, _, _ in throw AWSClientError . accessDenied }
179
186
$0. cognito. resetPassword = mock
187
+ $0. environment. dbId = { nil }
180
188
} operation: {
181
189
try app. test ( . POST, " reset " , beforeRequest: { req in try req. content. encode ( [ " email " : " testemail " , " password " : " testpassword " , " confirmationCode " : " 123 " ] )
182
190
} , afterResponse: { res in
@@ -190,6 +198,7 @@ class PortalTests: AppTestCase {
190
198
struct SomeError : Error { }
191
199
let mock : @Sendable ( _ req: Request , _ username: String , _ password: String , _ confirmationCode: String ) async throws -> Void = { _, _, _, _ in throw SomeError ( ) }
192
200
$0. cognito. resetPassword = mock
201
+ $0. environment. dbId = { nil }
193
202
} operation: {
194
203
try app. test ( . POST, " reset " , beforeRequest: { req in try req. content. encode ( [ " email " : " testemail " , " password " : " testpassword " , " confirmationCode " : " 123 " ] )
195
204
} , afterResponse: { res in
@@ -202,6 +211,7 @@ class PortalTests: AppTestCase {
202
211
try withDependencies {
203
212
let mock : @Sendable ( _ req: Request , _ username: String ) async throws -> Void = { _, _ in }
204
213
$0. cognito. forgotPassword = mock
214
+ $0. environment. dbId = { nil }
205
215
} operation: {
206
216
try app. test ( . POST, " forgot-password " , beforeRequest: { req in try req. content. encode ( [ " email " : " testemail " ] )
207
217
} , afterResponse: { res in
@@ -216,6 +226,7 @@ class PortalTests: AppTestCase {
216
226
struct SomeError : Error { }
217
227
let mock : @Sendable ( _ req: Request , _ username: String ) async throws -> Void = { _, _ in throw SomeError ( ) }
218
228
$0. cognito. forgotPassword = mock
229
+ $0. environment. dbId = { nil }
219
230
} operation: {
220
231
try app. test ( . POST, " forgot-password " , beforeRequest: { req in try req. content. encode ( [ " email " : " testemail " ] )
221
232
} , afterResponse: { res in
@@ -245,6 +256,7 @@ class PortalTests: AppTestCase {
245
256
try withDependencies {
246
257
let mock : @Sendable ( _ req: Request , _ username: String , _ confirmationCode: String ) async throws -> Void = { _, _, _ in }
247
258
$0. cognito. confirmSignUp = mock
259
+ $0. environment. dbId = { nil }
248
260
} operation: {
249
261
try app. test ( . POST, " verify " , beforeRequest: { req in try req. content. encode ( [ " email " : " testemail " , " confirmationCode " : " 123 " ] )
250
262
} , afterResponse: { res in
@@ -258,6 +270,7 @@ class PortalTests: AppTestCase {
258
270
try withDependencies {
259
271
let mock : @Sendable ( _ req: Request , _ username: String , _ confirmationCode: String ) async throws -> Void = { _, _, _ in throw AWSClientError . accessDenied }
260
272
$0. cognito. confirmSignUp = mock
273
+ $0. environment. dbId = { nil }
261
274
} operation: {
262
275
try app. test ( . POST, " verify " , beforeRequest: { req in try req. content. encode ( [ " email " : " testemail " , " confirmationCode " : " 123 " ] )
263
276
} , afterResponse: { res in
@@ -271,6 +284,7 @@ class PortalTests: AppTestCase {
271
284
struct SomeError : Error { }
272
285
let mock : @Sendable ( _ req: Request , _ username: String , _ confirmationCode: String ) async throws -> Void = { _, _, _ in throw SomeError ( ) }
273
286
$0. cognito. confirmSignUp = mock
287
+ $0. environment. dbId = { nil }
274
288
} operation: {
275
289
try app. test ( . POST, " verify " , beforeRequest: { req in try req. content. encode ( [ " email " : " testemail " , " confirmationCode " : " 123 " ] )
276
290
} , afterResponse: { res in
@@ -310,6 +324,7 @@ class PortalTests: AppTestCase {
310
324
struct SomeError : Error { }
311
325
let mock : @Sendable ( _ req: Request ) async throws -> Void = { _ in throw SomeError ( ) }
312
326
$0. cognito. deleteUser = mock
327
+ $0. environment. dbId = { nil }
313
328
} operation: {
314
329
try app. test ( . POST, " delete " ) { res in
315
330
XCTAssertEqual ( res. status, . internalServerError)
0 commit comments