Skip to content

Commit fc8cd1d

Browse files
committed
combine with the test from #9325
1 parent e2f0ac5 commit fc8cd1d

File tree

1 file changed

+2
-132
lines changed
  • nexus/tests/integration_tests

1 file changed

+2
-132
lines changed

nexus/tests/integration_tests/scim.rs

Lines changed: 2 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,7 +1992,7 @@ async fn test_scim_user_admin_group_priv_conflict(
19921992
}
19931993

19941994
#[nexus_test]
1995-
async fn test_scim_list_users_with_groups(cptestctx: &ControlPlaneTestContext) {
1995+
async fn test_scim_list_users_and_groups(cptestctx: &ControlPlaneTestContext) {
19961996
let client = &cptestctx.external_client;
19971997
let nexus = &cptestctx.server.server_context().nexus;
19981998
let opctx = OpContext::for_tests(
@@ -2098,7 +2098,7 @@ async fn test_scim_list_users_with_groups(cptestctx: &ControlPlaneTestContext) {
20982098
.execute_and_parse_unwrap()
20992099
.await;
21002100

2101-
let _group3: scim2_rs::Group = NexusRequest::new(
2101+
let group3: scim2_rs::Group = NexusRequest::new(
21022102
RequestBuilder::new(client, Method::POST, "/scim/v2/Groups")
21032103
.header(http::header::CONTENT_TYPE, "application/scim+json")
21042104
.header(
@@ -2181,136 +2181,6 @@ async fn test_scim_list_users_with_groups(cptestctx: &ControlPlaneTestContext) {
21812181
// user5 should have no groups
21822182
let user5 = find_user(&users[4].id);
21832183
assert!(user5.groups.is_none());
2184-
}
2185-
2186-
#[nexus_test]
2187-
async fn test_scim_list_groups_with_members(
2188-
cptestctx: &ControlPlaneTestContext,
2189-
) {
2190-
let client = &cptestctx.external_client;
2191-
let nexus = &cptestctx.server.server_context().nexus;
2192-
let opctx = OpContext::for_tests(
2193-
cptestctx.logctx.log.new(o!()),
2194-
nexus.datastore().clone(),
2195-
);
2196-
2197-
const SILO_NAME: &str = "saml-scim-silo";
2198-
create_silo(&client, SILO_NAME, true, shared::SiloIdentityMode::SamlScim)
2199-
.await;
2200-
2201-
grant_iam(
2202-
client,
2203-
&format!("/v1/system/silos/{SILO_NAME}"),
2204-
shared::SiloRole::Admin,
2205-
opctx.authn.actor().unwrap().silo_user_id().unwrap(),
2206-
AuthnMode::PrivilegedUser,
2207-
)
2208-
.await;
2209-
2210-
let created_token: views::ScimClientBearerTokenValue =
2211-
object_create_no_body(
2212-
client,
2213-
&format!("/v1/system/scim/tokens?silo={}", SILO_NAME),
2214-
)
2215-
.await;
2216-
2217-
// Create 5 users
2218-
let mut users = Vec::new();
2219-
for i in 1..=5 {
2220-
let user: scim2_rs::User = NexusRequest::new(
2221-
RequestBuilder::new(client, Method::POST, "/scim/v2/Users")
2222-
.header(http::header::CONTENT_TYPE, "application/scim+json")
2223-
.header(
2224-
http::header::AUTHORIZATION,
2225-
format!("Bearer oxide-scim-{}", created_token.bearer_token),
2226-
)
2227-
.allow_non_dropshot_errors()
2228-
.raw_body(Some(
2229-
serde_json::to_string(&serde_json::json!({
2230-
"userName": format!("user{}", i),
2231-
"externalId": format!("user{}@example.com", i),
2232-
}))
2233-
.unwrap(),
2234-
))
2235-
.expect_status(Some(StatusCode::CREATED)),
2236-
)
2237-
.execute_and_parse_unwrap()
2238-
.await;
2239-
users.push(user);
2240-
}
2241-
2242-
// Create 3 groups with various membership patterns:
2243-
// - group1: user1, user2, user3
2244-
// - group2: user1, user4
2245-
// - group3: no members
2246-
let group1: scim2_rs::Group = NexusRequest::new(
2247-
RequestBuilder::new(client, Method::POST, "/scim/v2/Groups")
2248-
.header(http::header::CONTENT_TYPE, "application/scim+json")
2249-
.header(
2250-
http::header::AUTHORIZATION,
2251-
format!("Bearer oxide-scim-{}", created_token.bearer_token),
2252-
)
2253-
.allow_non_dropshot_errors()
2254-
.raw_body(Some(
2255-
serde_json::to_string(&serde_json::json!({
2256-
"displayName": "group1",
2257-
"externalId": "group1@example.com",
2258-
"members": [
2259-
{"value": users[0].id},
2260-
{"value": users[1].id},
2261-
{"value": users[2].id},
2262-
],
2263-
}))
2264-
.unwrap(),
2265-
))
2266-
.expect_status(Some(StatusCode::CREATED)),
2267-
)
2268-
.execute_and_parse_unwrap()
2269-
.await;
2270-
2271-
let group2: scim2_rs::Group = NexusRequest::new(
2272-
RequestBuilder::new(client, Method::POST, "/scim/v2/Groups")
2273-
.header(http::header::CONTENT_TYPE, "application/scim+json")
2274-
.header(
2275-
http::header::AUTHORIZATION,
2276-
format!("Bearer oxide-scim-{}", created_token.bearer_token),
2277-
)
2278-
.allow_non_dropshot_errors()
2279-
.raw_body(Some(
2280-
serde_json::to_string(&serde_json::json!({
2281-
"displayName": "group2",
2282-
"externalId": "group2@example.com",
2283-
"members": [
2284-
{"value": users[0].id},
2285-
{"value": users[3].id},
2286-
],
2287-
}))
2288-
.unwrap(),
2289-
))
2290-
.expect_status(Some(StatusCode::CREATED)),
2291-
)
2292-
.execute_and_parse_unwrap()
2293-
.await;
2294-
2295-
let group3: scim2_rs::Group = NexusRequest::new(
2296-
RequestBuilder::new(client, Method::POST, "/scim/v2/Groups")
2297-
.header(http::header::CONTENT_TYPE, "application/scim+json")
2298-
.header(
2299-
http::header::AUTHORIZATION,
2300-
format!("Bearer oxide-scim-{}", created_token.bearer_token),
2301-
)
2302-
.allow_non_dropshot_errors()
2303-
.raw_body(Some(
2304-
serde_json::to_string(&serde_json::json!({
2305-
"displayName": "group3",
2306-
"externalId": "group3@example.com",
2307-
}))
2308-
.unwrap(),
2309-
))
2310-
.expect_status(Some(StatusCode::CREATED)),
2311-
)
2312-
.execute_and_parse_unwrap()
2313-
.await;
23142184

23152185
// List all groups and verify members
23162186
let response: scim2_rs::ListResponse = NexusRequest::new(

0 commit comments

Comments
 (0)