Browse Source

Reduce comments and redundant tests

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pull/7422/head
tom27052006 3 weeks ago
parent
commit
95fcdb90e8
  1. 4
      src/api/core/organizations.rs
  2. 8
      src/sso.rs

4
src/api/core/organizations.rs

@ -917,9 +917,9 @@ async fn get_org_details_impl(
Ok(json!(ciphers_json)) Ok(json!(ciphers_json))
} }
// Returning a Domain/Organization here allows the client to prefill it and prevents prompting the user. // Returning a Domain/Organization here allow to prefill it and prevent prompting the user
// Use the configured default organization so its policies apply during SSO enrollment; otherwise return a dummy value. // Use the configured default organization so its policies apply during SSO enrollment; otherwise return a dummy value.
// In use since `v2025.6.0`, the client appears to use only the first `organizationIdentifier`. // In use since `v2025.6.0`, appears to use only the first `organizationIdentifier`
#[post("/organizations/domain/sso/verified")] #[post("/organizations/domain/sso/verified")]
fn get_org_domain_sso_verified() -> JsonResult { fn get_org_domain_sso_verified() -> JsonResult {
let organization_identifier = match CONFIG.sso_default_organization_uuid() { let organization_identifier = match CONFIG.sso_default_organization_uuid() {

8
src/sso.rs

@ -392,8 +392,7 @@ async fn invite_user_to_default_organization(
Ok(()) Ok(())
} }
// `Uuid::parse_str` also accepts non-canonical forms (uppercase, braced, without hyphens), // Stored organization uuids are always lowercase hyphenated and compared as strings.
// while stored organization uuids are always lowercase hyphenated and compared as strings.
pub(crate) fn normalize_organization_uuid(org_uuid: &str) -> ApiResult<OrganizationId> { pub(crate) fn normalize_organization_uuid(org_uuid: &str) -> ApiResult<OrganizationId> {
let Ok(parsed) = uuid::Uuid::parse_str(org_uuid) else { let Ok(parsed) = uuid::Uuid::parse_str(org_uuid) else {
err!("`SSO_DEFAULT_ORGANIZATION_UUID` must be a valid UUID") err!("`SSO_DEFAULT_ORGANIZATION_UUID` must be a valid UUID")
@ -525,6 +524,7 @@ mod tests {
#[test] #[test]
fn normalizes_organization_uuid_to_canonical_form() { fn normalizes_organization_uuid_to_canonical_form() {
// `Uuid::parse_str` accepts uppercase, braced and unhyphenated forms.
for input in [ for input in [
"1B2C3D4E-5F60-7182-93A4-B5C6D7E8F901", "1B2C3D4E-5F60-7182-93A4-B5C6D7E8F901",
"{1b2c3d4e-5f60-7182-93a4-b5c6d7e8f901}", "{1b2c3d4e-5f60-7182-93a4-b5c6d7e8f901}",
@ -533,10 +533,6 @@ mod tests {
let org_id = normalize_organization_uuid(input).expect("valid UUID form should be accepted"); let org_id = normalize_organization_uuid(input).expect("valid UUID form should be accepted");
assert_eq!(org_id.to_string(), "1b2c3d4e-5f60-7182-93a4-b5c6d7e8f901"); assert_eq!(org_id.to_string(), "1b2c3d4e-5f60-7182-93a4-b5c6d7e8f901");
} }
}
#[test]
fn rejects_invalid_organization_uuid() {
assert!(normalize_organization_uuid("not-a-uuid").is_err()); assert!(normalize_organization_uuid("not-a-uuid").is_err());
} }
} }

Loading…
Cancel
Save