File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Tests/HabitTrackerAppServerTests Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,28 @@ struct HabitTrackerAppServerLoginTests {
8383 }
8484 }
8585 }
86+
87+ @Test ( " Test User Login Fail - Wrong username and wrong password " )
88+ func testUserLoginFailureWrongUsernameAndWrongPassword( ) async throws {
89+ try await withApp ( configure: configure) { app in
90+ // Create user in this app instance
91+ try await createUser ( in: app)
92+
93+ // Now test login with the same app instance
94+ let loginCredentials = User ( username: " wronguser " , password: " wrongpassword " )
95+ try await app. testing ( ) . test ( . POST, " /api/login " ) { req in
96+ try req. content. encode ( loginCredentials)
97+ } afterResponse: { res in
98+ #expect( res. status == . badRequest)
99+ // Check that we get a meaningful error response (not empty)
100+ #expect( !res. body. string. isEmpty)
101+ #expect( res. body. string. contains ( " User not found " ) )
102+
103+ }
104+ }
105+ }
106+
107+
86108}
87109
88110
You can’t perform that action at this time.
0 commit comments