Registry testing - part 6
This commit is contained in:
@@ -260,12 +260,20 @@ impl RegistryGet for Server {
|
||||
|| get.properties.contains(&Property::DnsZoneFile) =>
|
||||
{
|
||||
let todo = "domain dns zone file";
|
||||
todo!()
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
get.insert(id, object.into_value());
|
||||
let mut object = object.into_value();
|
||||
if !extra_properties.is_empty()
|
||||
&& let JmapValue::Object(obj) = &mut object
|
||||
{
|
||||
for (key, value) in extra_properties {
|
||||
obj.insert_unchecked(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
get.insert(id, object);
|
||||
}
|
||||
|
||||
Ok(get.into_response())
|
||||
@@ -300,30 +308,9 @@ impl RegistryGetResponse<'_> {
|
||||
pub fn insert(&mut self, id: Id, mut object: JmapValue<'static>) {
|
||||
let object_map = object.as_object_mut().unwrap();
|
||||
|
||||
if self.is_tenant_filtered
|
||||
&& let Some(tenant_id) = self.access_token.tenant_id()
|
||||
{
|
||||
let expected_value = JmapValue::Element(RegistryValue::Id(Id::from(tenant_id)));
|
||||
for (key, value) in object_map.iter() {
|
||||
if matches!(key, Key::Property(Property::MemberTenantId))
|
||||
&& (value != &expected_value
|
||||
|| value
|
||||
.as_array()
|
||||
.is_none_or(|arr| !arr.contains(&expected_value)))
|
||||
{
|
||||
self.not_found(id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if self.is_tenant_filtered && self.access_token.tenant_id().is_some() {
|
||||
object_map.remove(&Key::Property(Property::MemberTenantId));
|
||||
} else if self.is_account_filtered {
|
||||
let expected_value = JmapValue::Element(RegistryValue::Id(self.account_id.into()));
|
||||
for (key, value) in object_map.iter() {
|
||||
if matches!(key, Key::Property(Property::AccountId)) && value != &expected_value {
|
||||
self.not_found(id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
object_map.remove(&Key::Property(Property::AccountId));
|
||||
}
|
||||
|
||||
|
||||
@@ -796,7 +796,7 @@ pub(crate) async fn credential_query(
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
fn validate_credential_permissions(
|
||||
pub(crate) fn validate_credential_permissions(
|
||||
access_token: &AccessToken,
|
||||
credential: &SecondaryCredential,
|
||||
) -> Result<(), SetError<Property>> {
|
||||
|
||||
@@ -322,6 +322,7 @@ pub(crate) async fn validate_tenant_quota(
|
||||
(ObjectType::OAuthClient, None, "OAuth clients")
|
||||
}
|
||||
TenantStorageQuota::MaxDkimKeys => (ObjectType::DkimSignature, None, "DKIM keys"),
|
||||
TenantStorageQuota::MaxDnsServers => (ObjectType::DnsServer, None, "DNS servers"),
|
||||
TenantStorageQuota::MaxDiskQuota => unreachable!(),
|
||||
};
|
||||
let query = RegistryQuery::new(object_type).with_tenant(tenant_id.into());
|
||||
|
||||
@@ -420,6 +420,9 @@ impl RegistrySet for Server {
|
||||
ObjectInner::OAuthClient(_) if is_create => {
|
||||
validate_tenant_quota(&set, TenantStorageQuota::MaxOauthClients).await?
|
||||
}
|
||||
ObjectInner::DnsServer(_) if is_create => {
|
||||
validate_tenant_quota(&set, TenantStorageQuota::MaxDnsServers).await?
|
||||
}
|
||||
_ => Ok(ObjectResponse::default()),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user