Skip to content

Commit 0190de8

Browse files
authored
Expose silo_id from endpoint (oxidecomputer#1796)
1 parent 37edc2a commit 0190de8

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

nexus/db-model/src/silo_user.rs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ impl From<SiloUser> for views::User {
3333
id: user.id(),
3434
// TODO the use of external_id as display_name is temporary
3535
display_name: user.external_id,
36+
silo_id: user.silo_id,
3637
}
3738
}
3839
}

nexus/tests/integration_tests/console_api.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ async fn test_session_me(cptestctx: &ControlPlaneTestContext) {
342342
priv_user,
343343
views::User {
344344
id: USER_TEST_PRIVILEGED.id(),
345-
display_name: USER_TEST_PRIVILEGED.external_id.clone()
345+
display_name: USER_TEST_PRIVILEGED.external_id.clone(),
346+
silo_id: DEFAULT_SILO.id(),
346347
}
347348
);
348349

@@ -359,7 +360,8 @@ async fn test_session_me(cptestctx: &ControlPlaneTestContext) {
359360
unpriv_user,
360361
views::User {
361362
id: USER_TEST_UNPRIVILEGED.id(),
362-
display_name: USER_TEST_UNPRIVILEGED.external_id.clone()
363+
display_name: USER_TEST_UNPRIVILEGED.external_id.clone(),
364+
silo_id: DEFAULT_SILO.id(),
363365
}
364366
);
365367
}

nexus/tests/integration_tests/silos.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -844,11 +844,13 @@ async fn test_silo_users_list(cptestctx: &ControlPlaneTestContext) {
844844
vec![
845845
views::User {
846846
id: USER_TEST_PRIVILEGED.id(),
847-
display_name: USER_TEST_PRIVILEGED.external_id.clone()
847+
display_name: USER_TEST_PRIVILEGED.external_id.clone(),
848+
silo_id: *SILO_ID,
848849
},
849850
views::User {
850851
id: USER_TEST_UNPRIVILEGED.id(),
851-
display_name: USER_TEST_UNPRIVILEGED.external_id.clone()
852+
display_name: USER_TEST_UNPRIVILEGED.external_id.clone(),
853+
silo_id: *SILO_ID,
852854
},
853855
]
854856
);
@@ -877,15 +879,18 @@ async fn test_silo_users_list(cptestctx: &ControlPlaneTestContext) {
877879
vec![
878880
views::User {
879881
id: USER_TEST_PRIVILEGED.id(),
880-
display_name: USER_TEST_PRIVILEGED.external_id.clone()
882+
display_name: USER_TEST_PRIVILEGED.external_id.clone(),
883+
silo_id: *SILO_ID,
881884
},
882885
views::User {
883886
id: USER_TEST_UNPRIVILEGED.id(),
884-
display_name: USER_TEST_UNPRIVILEGED.external_id.clone()
887+
display_name: USER_TEST_UNPRIVILEGED.external_id.clone(),
888+
silo_id: *SILO_ID,
885889
},
886890
views::User {
887891
id: new_silo_user_id,
888892
display_name: new_silo_user_external_id.into(),
893+
silo_id: *SILO_ID,
889894
},
890895
]
891896
);
@@ -929,6 +934,7 @@ async fn test_silo_users_list(cptestctx: &ControlPlaneTestContext) {
929934
vec![views::User {
930935
id: new_silo_user_id,
931936
display_name: new_silo_user_name,
937+
silo_id: silo.identity.id,
932938
}]
933939
);
934940

nexus/types/src/external_api/views.rs

+3
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ pub struct User {
317317
pub id: Uuid,
318318
/** Human-readable name that can identify the user */
319319
pub display_name: String,
320+
321+
/** Uuid of the silo to which this user belongs */
322+
pub silo_id: Uuid,
320323
}
321324

322325
// BUILT-IN USERS

openapi/nexus.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -11188,11 +11188,17 @@
1118811188
"id": {
1118911189
"type": "string",
1119011190
"format": "uuid"
11191+
},
11192+
"silo_id": {
11193+
"description": "Uuid of the silo to which this user belongs",
11194+
"type": "string",
11195+
"format": "uuid"
1119111196
}
1119211197
},
1119311198
"required": [
1119411199
"display_name",
11195-
"id"
11200+
"id",
11201+
"silo_id"
1119611202
]
1119711203
},
1119811204
"UserBuiltin": {

0 commit comments

Comments
 (0)