mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-24 04:57:00 +01:00
fmt
This commit is contained in:
parent
30505f8285
commit
b148f353e3
|
@ -552,9 +552,7 @@ mod tests {
|
|||
use super::super::audit::AuditScope;
|
||||
use super::super::entry::{Entry, EntryInvalid, EntryNew};
|
||||
use super::super::filter::Filter;
|
||||
use super::{
|
||||
Backend, BackendError, BackendReadTransaction, BackendWriteTransaction,
|
||||
};
|
||||
use super::{Backend, BackendError, BackendReadTransaction, BackendWriteTransaction};
|
||||
|
||||
macro_rules! run_test {
|
||||
($test_fn:expr) => {{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
use super::proto_v1::Entry as ProtoEntry;
|
||||
use error::SchemaError;
|
||||
use filter::{Filter, FilterValid};
|
||||
use modify::{Modify, ModifyList, ModifyValid, ModifyInvalid};
|
||||
use modify::{Modify, ModifyInvalid, ModifyList, ModifyValid};
|
||||
use schema::{SchemaAttribute, SchemaClass, SchemaReadTransaction};
|
||||
use std::collections::btree_map::{Iter as BTreeIter, IterMut as BTreeIterMut};
|
||||
use std::collections::BTreeMap;
|
||||
|
@ -645,7 +645,10 @@ where
|
|||
}
|
||||
|
||||
// Should this be schemaless, relying on checks of the modlist, and the entry validate after?
|
||||
pub fn apply_modlist(&self, modlist: &ModifyList<ModifyValid>) -> Result<Entry<EntryInvalid, STATE>, ()> {
|
||||
pub fn apply_modlist(
|
||||
&self,
|
||||
modlist: &ModifyList<ModifyValid>,
|
||||
) -> Result<Entry<EntryInvalid, STATE>, ()> {
|
||||
// Apply a modlist, generating a new entry that conforms to the changes.
|
||||
// This is effectively clone-and-transform
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use super::proto_v1::{
|
|||
};
|
||||
use entry::{Entry, EntryCommitted, EntryInvalid, EntryNew, EntryValid};
|
||||
// use error::OperationError;
|
||||
use modify::{ModifyList, ModifyInvalid};
|
||||
use modify::{ModifyInvalid, ModifyList};
|
||||
|
||||
use actix::prelude::*;
|
||||
|
||||
|
|
|
@ -51,19 +51,18 @@ impl<'a> IntoIterator for &'a ModifyList<ModifyValid> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
impl ModifyList<ModifyInvalid> {
|
||||
pub fn new() -> Self {
|
||||
ModifyList {
|
||||
valid: ModifyInvalid,
|
||||
mods: Vec::new()
|
||||
mods: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_list(mods: Vec<Modify>) -> Self {
|
||||
ModifyList {
|
||||
valid: ModifyInvalid,
|
||||
mods: mods
|
||||
mods: mods,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,18 +78,18 @@ impl ModifyList<ModifyInvalid> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn validate(&self,
|
||||
pub fn validate(
|
||||
&self,
|
||||
schema: &SchemaReadTransaction,
|
||||
) -> Result<ModifyList<ModifyValid>, SchemaError> {
|
||||
|
||||
let schema_attributes = schema.get_attributes();
|
||||
let schema_name = schema_attributes
|
||||
.get("name")
|
||||
.expect("Critical: Core schema corrupt or missing. To initiate a core transfer, please deposit substitute core in receptacle.");
|
||||
|
||||
let res: Result<Vec<Modify>, _> = (&self.mods).into_iter()
|
||||
.map(|m| {
|
||||
match m {
|
||||
let res: Result<Vec<Modify>, _> = (&self.mods)
|
||||
.into_iter()
|
||||
.map(|m| match m {
|
||||
Modify::Present(attr, value) => {
|
||||
let attr_norm = schema_name.normalise_value(&attr);
|
||||
match schema_attributes.get(&attr_norm) {
|
||||
|
@ -118,13 +117,10 @@ impl ModifyList<ModifyInvalid> {
|
|||
Modify::Purged(attr) => {
|
||||
let attr_norm = schema_name.normalise_value(&attr);
|
||||
match schema_attributes.get(&attr_norm) {
|
||||
Some(_attr_name) => {
|
||||
Ok(Modify::Purged(attr_norm))
|
||||
}
|
||||
Some(_attr_name) => Ok(Modify::Purged(attr_norm)),
|
||||
None => Err(SchemaError::InvalidAttribute),
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -146,7 +142,7 @@ impl ModifyList<ModifyValid> {
|
|||
pub unsafe fn new_valid_list(mods: Vec<Modify>) -> Self {
|
||||
ModifyList {
|
||||
valid: ModifyValid,
|
||||
mods: mods
|
||||
mods: mods,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use entry::{Entry, EntryCommitted, EntryInvalid, EntryNew, EntryValid};
|
|||
use error::{OperationError, SchemaError};
|
||||
use event::{CreateEvent, DeleteEvent, ExistsEvent, ModifyEvent, ReviveRecycledEvent, SearchEvent};
|
||||
use filter::{Filter, FilterInvalid};
|
||||
use modify::{Modify, ModifyList, ModifyInvalid};
|
||||
use modify::{Modify, ModifyInvalid, ModifyList};
|
||||
use plugins::Plugins;
|
||||
use schema::{Schema, SchemaReadTransaction, SchemaTransaction, SchemaWriteTransaction};
|
||||
|
||||
|
@ -979,7 +979,6 @@ mod tests {
|
|||
*/
|
||||
use std::sync::Arc;
|
||||
|
||||
|
||||
use super::super::audit::AuditScope;
|
||||
use super::super::be::Backend;
|
||||
use super::super::entry::{Entry, EntryInvalid, EntryNew};
|
||||
|
@ -993,13 +992,10 @@ mod tests {
|
|||
use super::super::proto_v1::Modify as ProtoModify;
|
||||
use super::super::proto_v1::ModifyList as ProtoModifyList;
|
||||
use super::super::proto_v1::{
|
||||
DeleteRequest, ModifyRequest, ReviveRecycledRequest, SearchRecycledRequest,
|
||||
SearchRequest,
|
||||
DeleteRequest, ModifyRequest, ReviveRecycledRequest, SearchRecycledRequest, SearchRequest,
|
||||
};
|
||||
use super::super::schema::Schema;
|
||||
use super::super::server::{
|
||||
QueryServer, QueryServerReadTransaction
|
||||
};
|
||||
use super::super::server::{QueryServer, QueryServerReadTransaction};
|
||||
|
||||
macro_rules! run_test {
|
||||
($test_fn:expr) => {{
|
||||
|
|
Loading…
Reference in a new issue