Skip to content

Commit 6f75a02

Browse files
committed
Test fixes.
1 parent 4e62f82 commit 6f75a02

3 files changed

Lines changed: 57 additions & 0 deletions

File tree

src/NuGetGallery.Services/Permissions/ActionRequiringEntityPermissions.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,25 @@ public PermissionsCheckResult CheckPermissionsOnBehalfOfAnyAccount(User currentU
6363
return CheckPermissionsOnBehalfOfAnyAccount(currentUser, entity, exitEarly: false, accountsAllowedOnBehalfOf: out accountsAllowedOnBehalfOf);
6464
}
6565

66+
public override bool Equals(object obj)
67+
{
68+
if (obj == null)
69+
{
70+
return false;
71+
}
72+
var other = obj as ActionRequiringEntityPermissions<TEntity>;
73+
if (other == null)
74+
{
75+
return false;
76+
}
77+
return AccountOnBehalfOfPermissionsRequirement == other.AccountOnBehalfOfPermissionsRequirement;
78+
}
79+
80+
public override int GetHashCode()
81+
{
82+
return AccountOnBehalfOfPermissionsRequirement.GetHashCode();
83+
}
84+
6685
private PermissionsCheckResult CheckPermissionsOnBehalfOfAnyAccount(User currentUser, TEntity entity, bool exitEarly, out IEnumerable<User> accountsAllowedOnBehalfOf)
6786
{
6887
accountsAllowedOnBehalfOf = new List<User>();

src/NuGetGallery.Services/Permissions/ActionRequiringPackagePermissions.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ public PermissionsCheckResult CheckPermissionsOnBehalfOfAnyAccount(User currentU
4949
return CheckPermissionsOnBehalfOfAnyAccount(currentUser, GetPackageRegistration(package), out accountsAllowedOnBehalfOf);
5050
}
5151

52+
public override bool Equals(object obj)
53+
{
54+
if (!base.Equals(obj))
55+
{
56+
return false;
57+
}
58+
var other = obj as ActionRequiringPackagePermissions;
59+
if (other == null)
60+
{
61+
return false;
62+
}
63+
return PackageRegistrationPermissionsRequirement == other.PackageRegistrationPermissionsRequirement;
64+
}
65+
66+
public override int GetHashCode()
67+
{
68+
return base.GetHashCode() ^ PackageRegistrationPermissionsRequirement.GetHashCode();
69+
}
70+
5271
protected override IEnumerable<User> GetOwners(PackageRegistration packageRegistration)
5372
{
5473
return packageRegistration != null ? packageRegistration.Owners : Enumerable.Empty<User>();

src/NuGetGallery.Services/Permissions/ActionRequiringReservedNamespacePermissions.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,25 @@ public PermissionsCheckResult CheckPermissions(IPrincipal currentPrincipal, User
5050
return CheckPermissions(currentPrincipal, account, GetReservedNamespaces(reservedNamespace));
5151
}
5252

53+
public override bool Equals(object obj)
54+
{
55+
if (!base.Equals(obj))
56+
{
57+
return false;
58+
}
59+
var other = obj as ActionRequiringReservedNamespacePermissions;
60+
if (other == null)
61+
{
62+
return false;
63+
}
64+
return ReservedNamespacePermissionsRequirement == other.ReservedNamespacePermissionsRequirement;
65+
}
66+
67+
public override int GetHashCode()
68+
{
69+
return base.GetHashCode() ^ ReservedNamespacePermissionsRequirement.GetHashCode();
70+
}
71+
5372
protected override PermissionsCheckResult CheckPermissionsForEntity(User account, IReadOnlyCollection<ReservedNamespace> reservedNamespaces)
5473
{
5574
if (!reservedNamespaces.Any())

0 commit comments

Comments
 (0)