summaryrefslogtreecommitdiffstats
path: root/tests/admin.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/admin.rs')
-rw-r--r--tests/admin.rs88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/admin.rs b/tests/admin.rs
index 6b82fab..674ca16 100644
--- a/tests/admin.rs
+++ b/tests/admin.rs
@@ -188,3 +188,91 @@ async fn hook() {
.await
.expect("failed to delete hook");
}
+
+#[tokio::test]
+async fn quota_group() {
+ let api = common::login();
+
+ let user_opts = CreateUserOption {
+ created_at: None,
+ email: "1997@example.com".into(),
+ full_name: None,
+ login_name: None,
+ must_change_password: None,
+ password: Some("dialtone".into()),
+ restricted: None,
+ send_notify: None,
+ source_id: None,
+ username: "salesman".into(),
+ visibility: None,
+ };
+ api.admin_create_user(user_opts)
+ .await
+ .expect("failed to create user");
+
+ let group = CreateQuotaGroupOptions {
+ name: Some("no doing anything".into()),
+ rules: Some(vec![CreateQuotaRuleOptions {
+ limit: Some(0),
+ name: Some("blah".into()),
+ subjects: Some(vec![CreateQuotaRuleOptionsSubjects::SizeAll]),
+ }]),
+ };
+ let quota_group = api
+ .admin_create_quota_group(group)
+ .await
+ .expect("failed to create quota group");
+
+ api.admin_add_user_to_quota_group("no doing anything", "salesman")
+ .await
+ .expect("failed to add user to quota group");
+
+ assert!(quota_group
+ .name
+ .as_ref()
+ .is_some_and(|name| name == "no doing anything"));
+ assert!(quota_group
+ .rules
+ .as_ref()
+ .is_some_and(|rules| rules.len() == 1));
+
+ let quota_groups = api
+ .admin_list_quota_groups()
+ .await
+ .expect("failed to list quota groups");
+ assert_eq!(quota_groups.len(), 1);
+ assert_eq!(&quota_groups[0], &quota_group);
+
+ let quota_info = api
+ .admin_get_user_quota("salesman")
+ .await
+ .expect("failed to get user quota");
+ let usage = quota_info
+ .used
+ .expect("quota info missing usage info")
+ .size
+ .expect("quota info missing size info");
+ assert!(usage
+ .git
+ .is_some_and(|git| git.lfs.is_some_and(|lfs| lfs == 0)));
+ assert!(usage
+ .repos
+ .as_ref()
+ .is_some_and(|repos| repos.public.is_some_and(|lfs| lfs == 0)));
+ assert!(usage
+ .repos
+ .is_some_and(|repos| repos.private.is_some_and(|lfs| lfs == 0)));
+ assert!(usage
+ .assets
+ .is_some_and(|assets| assets.artifacts.is_some_and(|lfs| lfs == 0)));
+
+ api.admin_remove_rule_from_quota_group("no doing anything", "blah")
+ .await
+ .expect("failed to delete rule from quota group");
+ api.admin_remove_user_from_quota_group("no doing anything", "salesman")
+ .await
+ .expect("failed to remove user from quota group");
+ api.admin_delete_quota_group("no doing anything")
+ .await
+ .expect("failed to delete quota group");
+}