Skip to content

Commit 53e4079

Browse files
committed
test: validate no legacy login if google account linked
Add an integration test to ensure that if a google account is linked to a pointercrate account, that pointercrate account becomes impossible to log in via username/password combo. Signed-off-by: stadust <[email protected]>
1 parent 8c13be5 commit 53e4079

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

pointercrate-test/tests/user/login.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,32 @@ pub async fn test_login_no_header(pool: Pool<Postgres>) {
100100
.execute()
101101
.await;
102102
}
103+
104+
#[sqlx::test(migrations = "../migrations")]
105+
pub async fn test_no_login_if_google_account_linked(pool: Pool<Postgres>) {
106+
let (client, mut connection) = pointercrate_test::user::setup_rocket(pool).await;
107+
108+
// Make sure the user we're trying to log in to exists
109+
let user = pointercrate_test::user::system_user_with_perms(ADMINISTRATOR, &mut *connection).await;
110+
111+
client
112+
.post("/api/v1/auth/", &())
113+
.header("Authorization", "Basic UGF0cmljazpiYWQgcGFzc3dvcmQ=")
114+
.header("X-Real-IP", "127.0.0.1")
115+
.expect_status(Status::Ok)
116+
.execute()
117+
.await;
118+
119+
sqlx::query!("UPDATE members SET google_account_id='1' WHERE member_id=$1", user.user().id)
120+
.execute(&mut *connection)
121+
.await
122+
.unwrap();
123+
124+
client
125+
.post("/api/v1/auth/", &())
126+
.header("Authorization", "Basic UGF0cmljazpiYWQgcGFzc3dvcmQ=")
127+
.header("X-Real-IP", "127.0.0.1")
128+
.expect_status(Status::Unauthorized)
129+
.execute()
130+
.await;
131+
}

0 commit comments

Comments
 (0)