Skip to content

Commit 239505c

Browse files
committed
chore(labrinth): add users to zeta organization during tests
1 parent 8741dd0 commit 239505c

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

apps/labrinth/tests/scopes.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use common::environment::{
2222
use common::{database::*, scopes::ScopeTest};
2323
use labrinth::models::ids::ProjectId;
2424
use labrinth::models::pats::Scopes;
25+
use labrinth::models::teams::ProjectPermissions;
2526
use serde_json::json;
2627
// For each scope, we (using test_scope):
2728
// - create a PAT with a given set of scopes for a function
@@ -1093,6 +1094,7 @@ pub async fn organization_scopes() {
10931094
.await
10941095
.unwrap();
10951096
let organization_id = success["id"].as_str().unwrap();
1097+
let organization_team_id = success["team_id"].as_str().unwrap();
10961098

10971099
// Patch organization
10981100
let organization_edit = Scopes::ORGANIZATION_WRITE;
@@ -1154,6 +1156,27 @@ pub async fn organization_scopes() {
11541156
.await
11551157
.unwrap();
11561158

1159+
// Add two members to the organization
1160+
api.add_user_to_team(
1161+
organization_team_id,
1162+
FRIEND_USER_ID,
1163+
Some(ProjectPermissions::all()),
1164+
None,
1165+
USER_USER_PAT,
1166+
)
1167+
.await;
1168+
api.join_team(organization_team_id, FRIEND_USER_PAT).await;
1169+
1170+
api.add_user_to_team(
1171+
organization_team_id,
1172+
ENEMY_USER_ID,
1173+
Some(ProjectPermissions::all()),
1174+
None,
1175+
USER_USER_PAT,
1176+
)
1177+
.await;
1178+
api.join_team(organization_team_id, ENEMY_USER_PAT).await;
1179+
11571180
// Organization reads
11581181
let organization_read = Scopes::ORGANIZATION_READ;
11591182
let req_gen = |pat: Option<String>| async move {

apps/labrinth/tests/teams.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async fn test_get_team_organization() {
176176
&test_env.dummy.organization_zeta.organization_id;
177177
let zeta_team_id = &test_env.dummy.organization_zeta.team_id;
178178

179-
// A non-member of the team should get basic info but not be able to see private data
179+
// A non-member of the team should get basic team info
180180
let members = api
181181
.get_team_members_deserialized_common(
182182
zeta_team_id,
@@ -187,15 +187,6 @@ async fn test_get_team_organization() {
187187
assert_eq!(members[0].user.id.0, USER_USER_ID_PARSED as u64);
188188
assert!(members[0].permissions.is_none());
189189

190-
let members = api
191-
.get_organization_members_deserialized_common(
192-
zeta_organization_id,
193-
FRIEND_USER_PAT,
194-
)
195-
.await;
196-
assert_eq!(members.len(), 1);
197-
assert_eq!(members[0].user.id.0, USER_USER_ID_PARSED as u64);
198-
199190
// A non-accepted member of the team should:
200191
// - not be able to see private data about the team, but see all members including themselves
201192
// - should not appear in the team members list to enemy users
@@ -262,15 +253,6 @@ async fn test_get_team_organization() {
262253
.await;
263254
assert_eq!(members.len(), 1); // Only USER_USER_ID should be in the team
264255

265-
// enemy team check via association
266-
let members = api
267-
.get_organization_members_deserialized_common(
268-
zeta_organization_id,
269-
ENEMY_USER_PAT,
270-
)
271-
.await;
272-
assert_eq!(members.len(), 1); // Only USER_USER_ID should be in the team
273-
274256
// An accepted member of the team should appear in the team members list
275257
// and should be able to see private data about the team
276258
let resp = api.join_team(zeta_team_id, FRIEND_USER_PAT).await;

0 commit comments

Comments
 (0)