You've already forked lldap
mirror of
https://github.com/lldap/lldap.git
synced 2026-04-05 12:32:57 +01:00
Fix tests and formatting for modifyTimestamp implementation
Co-authored-by: nitnelave <796633+nitnelave@users.noreply.github.com>
This commit is contained in:
Generated
+1
@@ -2729,6 +2729,7 @@ dependencies = [
|
|||||||
"lldap_domain_handlers",
|
"lldap_domain_handlers",
|
||||||
"lldap_domain_model",
|
"lldap_domain_model",
|
||||||
"lldap_ldap",
|
"lldap_ldap",
|
||||||
|
"lldap_opaque_handler",
|
||||||
"lldap_sql_backend_handler",
|
"lldap_sql_backend_handler",
|
||||||
"lldap_test_utils",
|
"lldap_test_utils",
|
||||||
"lldap_validation",
|
"lldap_validation",
|
||||||
|
|||||||
@@ -55,20 +55,24 @@ version = "1"
|
|||||||
mockall = "0.11.4"
|
mockall = "0.11.4"
|
||||||
pretty_assertions = "1"
|
pretty_assertions = "1"
|
||||||
|
|
||||||
#[dev-dependencies.lldap_auth]
|
[dev-dependencies.lldap_auth]
|
||||||
#path = "../auth"
|
path = "../auth"
|
||||||
#features = ["test"]
|
features = ["test"]
|
||||||
#
|
|
||||||
#[dev-dependencies.lldap_opaque_handler]
|
[dev-dependencies.lldap_domain]
|
||||||
#path = "../opaque-handler"
|
path = "../domain"
|
||||||
#features = ["test"]
|
features = ["test"]
|
||||||
|
|
||||||
|
[dev-dependencies.lldap_opaque_handler]
|
||||||
|
path = "../opaque-handler"
|
||||||
|
features = ["test"]
|
||||||
|
|
||||||
[dev-dependencies.lldap_test_utils]
|
[dev-dependencies.lldap_test_utils]
|
||||||
path = "../test-utils"
|
path = "../test-utils"
|
||||||
#
|
|
||||||
#[dev-dependencies.lldap_sql_backend_handler]
|
[dev-dependencies.lldap_sql_backend_handler]
|
||||||
#path = "../sql-backend-handler"
|
path = "../sql-backend-handler"
|
||||||
#features = ["test"]
|
features = ["test"]
|
||||||
|
|
||||||
[dev-dependencies.tokio]
|
[dev-dependencies.tokio]
|
||||||
features = ["full"]
|
features = ["full"]
|
||||||
|
|||||||
@@ -999,6 +999,14 @@ mod tests {
|
|||||||
"name": "mail",
|
"name": "mail",
|
||||||
"value": ["bob@bobbers.on"],
|
"value": ["bob@bobbers.on"],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "modified_date",
|
||||||
|
"value": ["1970-01-01T00:00:00+00:00"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "password_modified_date",
|
||||||
|
"value": ["1970-01-01T00:00:00+00:00"],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "user_id",
|
"name": "user_id",
|
||||||
"value": ["bob"],
|
"value": ["bob"],
|
||||||
@@ -1032,6 +1040,10 @@ mod tests {
|
|||||||
"name": "group_id",
|
"name": "group_id",
|
||||||
"value": ["3"],
|
"value": ["3"],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "modified_date",
|
||||||
|
"value": ["1970-01-01T00:00:00.000000042+00:00"],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "uuid",
|
"name": "uuid",
|
||||||
"value": ["a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8"],
|
"value": ["a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8"],
|
||||||
@@ -1059,6 +1071,10 @@ mod tests {
|
|||||||
"name": "group_id",
|
"name": "group_id",
|
||||||
"value": ["7"],
|
"value": ["7"],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "modified_date",
|
||||||
|
"value": ["1970-01-01T00:00:00.000000012+00:00"],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "uuid",
|
"name": "uuid",
|
||||||
"value": ["b1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8"],
|
"value": ["b1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8"],
|
||||||
@@ -1252,6 +1268,22 @@ mod tests {
|
|||||||
"isEditable": true,
|
"isEditable": true,
|
||||||
"isHardcoded": true,
|
"isHardcoded": true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "modified_date",
|
||||||
|
"attributeType": "DATE_TIME",
|
||||||
|
"isList": false,
|
||||||
|
"isVisible": true,
|
||||||
|
"isEditable": false,
|
||||||
|
"isHardcoded": true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "password_modified_date",
|
||||||
|
"attributeType": "DATE_TIME",
|
||||||
|
"isList": false,
|
||||||
|
"isVisible": true,
|
||||||
|
"isEditable": false,
|
||||||
|
"isHardcoded": true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "user_id",
|
"name": "user_id",
|
||||||
"attributeType": "STRING",
|
"attributeType": "STRING",
|
||||||
@@ -1297,6 +1329,14 @@ mod tests {
|
|||||||
"isEditable": false,
|
"isEditable": false,
|
||||||
"isHardcoded": true,
|
"isHardcoded": true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "modified_date",
|
||||||
|
"attributeType": "DATE_TIME",
|
||||||
|
"isList": false,
|
||||||
|
"isVisible": true,
|
||||||
|
"isEditable": false,
|
||||||
|
"isHardcoded": true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "uuid",
|
"name": "uuid",
|
||||||
"attributeType": "STRING",
|
"attributeType": "STRING",
|
||||||
@@ -1371,6 +1411,8 @@ mod tests {
|
|||||||
{"name": "creation_date"},
|
{"name": "creation_date"},
|
||||||
{"name": "display_name"},
|
{"name": "display_name"},
|
||||||
{"name": "mail"},
|
{"name": "mail"},
|
||||||
|
{"name": "modified_date"},
|
||||||
|
{"name": "password_modified_date"},
|
||||||
{"name": "user_id"},
|
{"name": "user_id"},
|
||||||
{"name": "uuid"},
|
{"name": "uuid"},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ mod tests {
|
|||||||
users: vec![UserId::new("bob")],
|
users: vec![UserId::new("bob")],
|
||||||
uuid: uuid!("04ac75e0-2900-3e21-926c-2f732c26b3fc"),
|
uuid: uuid!("04ac75e0-2900-3e21-926c-2f732c26b3fc"),
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
||||||
}])
|
}])
|
||||||
});
|
});
|
||||||
let ldap_handler = setup_bound_admin_handler(mock).await;
|
let ldap_handler = setup_bound_admin_handler(mock).await;
|
||||||
@@ -219,7 +219,7 @@ mod tests {
|
|||||||
users: vec![UserId::new("bob")],
|
users: vec![UserId::new("bob")],
|
||||||
uuid: uuid!("04ac75e0-2900-3e21-926c-2f732c26b3fc"),
|
uuid: uuid!("04ac75e0-2900-3e21-926c-2f732c26b3fc"),
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
||||||
}])
|
}])
|
||||||
});
|
});
|
||||||
let ldap_handler = setup_bound_admin_handler(mock).await;
|
let ldap_handler = setup_bound_admin_handler(mock).await;
|
||||||
|
|||||||
@@ -279,12 +279,8 @@ pub fn map_group_field(field: &AttributeName, schema: &PublicSchema) -> GroupFie
|
|||||||
"entrydn" => GroupFieldType::EntryDn,
|
"entrydn" => GroupFieldType::EntryDn,
|
||||||
"objectclass" => GroupFieldType::ObjectClass,
|
"objectclass" => GroupFieldType::ObjectClass,
|
||||||
"cn" | "displayname" | "uid" | "display_name" | "id" => GroupFieldType::DisplayName,
|
"cn" | "displayname" | "uid" | "display_name" | "id" => GroupFieldType::DisplayName,
|
||||||
"creationdate" | "createtimestamp" | "creation_date" => {
|
"creationdate" | "createtimestamp" | "creation_date" => GroupFieldType::CreationDate,
|
||||||
GroupFieldType::CreationDate
|
"modifytimestamp" | "modifydate" | "modified_date" => GroupFieldType::ModifiedDate,
|
||||||
}
|
|
||||||
"modifytimestamp" | "modifydate" | "modified_date" => {
|
|
||||||
GroupFieldType::ModifiedDate
|
|
||||||
}
|
|
||||||
"member" | "uniquemember" => GroupFieldType::Member,
|
"member" | "uniquemember" => GroupFieldType::Member,
|
||||||
"entryuuid" | "uuid" => GroupFieldType::Uuid,
|
"entryuuid" | "uuid" => GroupFieldType::Uuid,
|
||||||
"group_id" | "groupid" => GroupFieldType::GroupId,
|
"group_id" | "groupid" => GroupFieldType::GroupId,
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ mod tests {
|
|||||||
creation_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
creation_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
||||||
uuid: uuid!("a1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8"),
|
uuid: uuid!("a1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8"),
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Ok(g)
|
Ok(g)
|
||||||
|
|||||||
@@ -521,7 +521,7 @@ pub mod tests {
|
|||||||
creation_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
creation_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
||||||
uuid: uuid!("a1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8"),
|
uuid: uuid!("a1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8"),
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
||||||
});
|
});
|
||||||
mock.expect_get_user_groups()
|
mock.expect_get_user_groups()
|
||||||
.with(eq(UserId::new("bob")))
|
.with(eq(UserId::new("bob")))
|
||||||
|
|||||||
@@ -636,8 +636,11 @@ mod tests {
|
|||||||
b"( 10.5 NAME 'first_name' DESC 'LLDAP: builtin attribute' SUP String )"
|
b"( 10.5 NAME 'first_name' DESC 'LLDAP: builtin attribute' SUP String )"
|
||||||
.to_vec(),
|
.to_vec(),
|
||||||
b"( 10.6 NAME 'mail' DESC 'LLDAP: builtin attribute' SUP String )".to_vec(),
|
b"( 10.6 NAME 'mail' DESC 'LLDAP: builtin attribute' SUP String )".to_vec(),
|
||||||
b"( 10.7 NAME 'group_id' DESC 'LLDAP: builtin attribute' SUP Integer )"
|
b"( 10.7 NAME 'modified_date' DESC 'LLDAP: builtin attribute' SUP DateTime )".to_vec(),
|
||||||
|
b"( 10.8 NAME 'password_modified_date' DESC 'LLDAP: builtin attribute' SUP DateTime )".to_vec(),
|
||||||
|
b"( 10.9 NAME 'group_id' DESC 'LLDAP: builtin attribute' SUP Integer )"
|
||||||
.to_vec(),
|
.to_vec(),
|
||||||
|
b"( 10.10 NAME 'modified_date' DESC 'LLDAP: builtin attribute' SUP DateTime )".to_vec(),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -646,8 +649,8 @@ mod tests {
|
|||||||
LdapPartialAttribute {
|
LdapPartialAttribute {
|
||||||
atype: "objectClasses".to_owned(),
|
atype: "objectClasses".to_owned(),
|
||||||
vals: vec![
|
vals: vec![
|
||||||
b"( 3.0 NAME ( 'inetOrgPerson' 'posixAccount' 'mailAccount' 'person' 'customUserClass' ) DESC 'LLDAP builtin: a person' STRUCTURAL MUST ( mail $ user_id ) MAY ( avatar $ creation_date $ display_name $ first_name $ last_name $ uuid ) )".to_vec(),
|
b"( 3.0 NAME ( 'inetOrgPerson' 'posixAccount' 'mailAccount' 'person' 'customUserClass' ) DESC 'LLDAP builtin: a person' STRUCTURAL MUST ( mail $ user_id ) MAY ( avatar $ creation_date $ display_name $ first_name $ last_name $ modified_date $ password_modified_date $ uuid ) )".to_vec(),
|
||||||
b"( 3.1 NAME ( 'groupOfUniqueNames' 'groupOfNames' ) DESC 'LLDAP builtin: a group' STRUCTURAL MUST ( display_name ) MAY ( creation_date $ group_id $ uuid ) )".to_vec(),
|
b"( 3.1 NAME ( 'groupOfUniqueNames' 'groupOfNames' ) DESC 'LLDAP builtin: a group' STRUCTURAL MUST ( display_name ) MAY ( creation_date $ group_id $ modified_date $ uuid ) )".to_vec(),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -1083,7 +1086,7 @@ mod tests {
|
|||||||
users: vec![UserId::new("bob"), UserId::new("john")],
|
users: vec![UserId::new("bob"), UserId::new("john")],
|
||||||
uuid: uuid!("04ac75e0-2900-3e21-926c-2f732c26b3fc"),
|
uuid: uuid!("04ac75e0-2900-3e21-926c-2f732c26b3fc"),
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
||||||
}])
|
}])
|
||||||
});
|
});
|
||||||
let ldap_handler = setup_bound_admin_handler(mock).await;
|
let ldap_handler = setup_bound_admin_handler(mock).await;
|
||||||
@@ -1134,7 +1137,7 @@ mod tests {
|
|||||||
users: vec![],
|
users: vec![],
|
||||||
uuid: uuid!("04ac75e0-2900-3e21-926c-2f732c26b3fc"),
|
uuid: uuid!("04ac75e0-2900-3e21-926c-2f732c26b3fc"),
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
||||||
}])
|
}])
|
||||||
});
|
});
|
||||||
let ldap_handler = setup_bound_admin_handler(mock).await;
|
let ldap_handler = setup_bound_admin_handler(mock).await;
|
||||||
@@ -1206,7 +1209,7 @@ mod tests {
|
|||||||
users: vec![],
|
users: vec![],
|
||||||
uuid: uuid!("04ac75e0-2900-3e21-926c-2f732c26b3fc"),
|
uuid: uuid!("04ac75e0-2900-3e21-926c-2f732c26b3fc"),
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
||||||
}])
|
}])
|
||||||
});
|
});
|
||||||
let ldap_handler = setup_bound_admin_handler(mock).await;
|
let ldap_handler = setup_bound_admin_handler(mock).await;
|
||||||
@@ -1716,7 +1719,7 @@ mod tests {
|
|||||||
users: vec![UserId::new("bob"), UserId::new("john")],
|
users: vec![UserId::new("bob"), UserId::new("john")],
|
||||||
uuid: uuid!("04ac75e0-2900-3e21-926c-2f732c26b3fc"),
|
uuid: uuid!("04ac75e0-2900-3e21-926c-2f732c26b3fc"),
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
||||||
}])
|
}])
|
||||||
});
|
});
|
||||||
let ldap_handler = setup_bound_admin_handler(mock).await;
|
let ldap_handler = setup_bound_admin_handler(mock).await;
|
||||||
@@ -1801,7 +1804,7 @@ mod tests {
|
|||||||
users: vec![UserId::new("bob"), UserId::new("john")],
|
users: vec![UserId::new("bob"), UserId::new("john")],
|
||||||
uuid: uuid!("04ac75e0-2900-3e21-926c-2f732c26b3fc"),
|
uuid: uuid!("04ac75e0-2900-3e21-926c-2f732c26b3fc"),
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
modified_date: chrono::Utc.timestamp_opt(42, 42).unwrap().naive_utc(),
|
||||||
}])
|
}])
|
||||||
});
|
});
|
||||||
let ldap_handler = setup_bound_admin_handler(mock).await;
|
let ldap_handler = setup_bound_admin_handler(mock).await;
|
||||||
|
|||||||
@@ -1121,14 +1121,12 @@ async fn migrate_to_v11(transaction: DatabaseTransaction) -> Result<DatabaseTran
|
|||||||
transaction
|
transaction
|
||||||
.execute(
|
.execute(
|
||||||
builder.build(
|
builder.build(
|
||||||
Table::alter()
|
Table::alter().table(Users::Table).add_column(
|
||||||
.table(Users::Table)
|
ColumnDef::new(Users::ModifiedDate)
|
||||||
.add_column(
|
.date_time()
|
||||||
ColumnDef::new(Users::ModifiedDate)
|
.not_null()
|
||||||
.date_time()
|
.default(chrono::Utc::now().naive_utc()),
|
||||||
.not_null()
|
),
|
||||||
.default(chrono::Utc::now().naive_utc()),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
@@ -1137,14 +1135,12 @@ async fn migrate_to_v11(transaction: DatabaseTransaction) -> Result<DatabaseTran
|
|||||||
transaction
|
transaction
|
||||||
.execute(
|
.execute(
|
||||||
builder.build(
|
builder.build(
|
||||||
Table::alter()
|
Table::alter().table(Users::Table).add_column(
|
||||||
.table(Users::Table)
|
ColumnDef::new(Users::PasswordModifiedDate)
|
||||||
.add_column(
|
.date_time()
|
||||||
ColumnDef::new(Users::PasswordModifiedDate)
|
.not_null()
|
||||||
.date_time()
|
.default(chrono::Utc::now().naive_utc()),
|
||||||
.not_null()
|
),
|
||||||
.default(chrono::Utc::now().naive_utc()),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
@@ -1153,14 +1149,12 @@ async fn migrate_to_v11(transaction: DatabaseTransaction) -> Result<DatabaseTran
|
|||||||
transaction
|
transaction
|
||||||
.execute(
|
.execute(
|
||||||
builder.build(
|
builder.build(
|
||||||
Table::alter()
|
Table::alter().table(Groups::Table).add_column(
|
||||||
.table(Groups::Table)
|
ColumnDef::new(Groups::ModifiedDate)
|
||||||
.add_column(
|
.date_time()
|
||||||
ColumnDef::new(Groups::ModifiedDate)
|
.not_null()
|
||||||
.date_time()
|
.default(chrono::Utc::now().naive_utc()),
|
||||||
.not_null()
|
),
|
||||||
.default(chrono::Utc::now().naive_utc()),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user