From f1164441c33033ca46a4b6b552127809d6d3e39e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rald=20Barr=C3=A9?= Date: Mon, 16 Jan 2023 18:04:34 -0500 Subject: [PATCH] Mock: groups correctly handle permissions for admin users (#369) --- NGitLab.Mock/Group.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/NGitLab.Mock/Group.cs b/NGitLab.Mock/Group.cs index 66e83c52..7c988062 100644 --- a/NGitLab.Mock/Group.cs +++ b/NGitLab.Mock/Group.cs @@ -177,6 +177,9 @@ public bool CanUserViewGroup(User user) if (user == null) return false; + if (user.IsAdmin) + return true; + var accessLevel = GetEffectivePermissions().GetAccessLevel(user); if (accessLevel.HasValue) return true; @@ -189,6 +192,9 @@ public bool CanUserDeleteGroup(User user) if (user == null) return false; + if (user.IsAdmin) + return true; + var accessLevel = GetEffectivePermissions().GetAccessLevel(user); return accessLevel.HasValue && accessLevel.Value == AccessLevel.Owner; } @@ -198,6 +204,9 @@ public bool CanUserEditGroup(User user) if (user == null) return false; + if (user.IsAdmin) + return true; + var accessLevel = GetEffectivePermissions().GetAccessLevel(user); return accessLevel.HasValue && accessLevel.Value >= AccessLevel.Maintainer; } @@ -207,6 +216,9 @@ public bool CanUserAddGroup(User user) if (user == null) return false; + if (user.IsAdmin) + return true; + var accessLevel = GetEffectivePermissions().GetAccessLevel(user); return accessLevel.HasValue && accessLevel.Value >= AccessLevel.Developer; } @@ -216,6 +228,9 @@ public bool CanUserAddProject(User user) if (user == null) return false; + if (user.IsAdmin) + return true; + var accessLevel = GetEffectivePermissions().GetAccessLevel(user); return accessLevel.HasValue && accessLevel.Value >= AccessLevel.Developer; }