Skip to content

Commit

Permalink
Mock: groups correctly handle permissions for admin users (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
meziantou authored Jan 16, 2023
1 parent bbf654a commit f116444
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions NGitLab.Mock/Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit f116444

Please sign in to comment.