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