acl: remove ACL.IsSame
The only caller of this method was removed in a recent commit along with replication.
This commit is contained in:
parent
4dd5bb8e3b
commit
4d5a39e622
|
@ -106,21 +106,6 @@ func (tok *ACLToken) Convert() (*ACL, error) {
|
||||||
return compat, nil
|
return compat, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsSame checks if one ACL is the same as another, without looking
|
|
||||||
// at the Raft information (that's why we didn't call it IsEqual). This is
|
|
||||||
// useful for seeing if an update would be idempotent for all the functional
|
|
||||||
// parts of the structure.
|
|
||||||
func (a *ACL) IsSame(other *ACL) bool {
|
|
||||||
if a.ID != other.ID ||
|
|
||||||
a.Name != other.Name ||
|
|
||||||
a.Type != other.Type ||
|
|
||||||
a.Rules != other.Rules {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// ACLRequest is used to create, update or delete an ACL
|
// ACLRequest is used to create, update or delete an ACL
|
||||||
type ACLRequest struct {
|
type ACLRequest struct {
|
||||||
Datacenter string
|
Datacenter string
|
||||||
|
|
|
@ -6,53 +6,6 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestStructs_ACL_IsSame(t *testing.T) {
|
|
||||||
acl := &ACL{
|
|
||||||
ID: "guid",
|
|
||||||
Name: "An ACL for testing",
|
|
||||||
Type: "client",
|
|
||||||
Rules: "service \"\" { policy = \"read\" }",
|
|
||||||
}
|
|
||||||
if !acl.IsSame(acl) {
|
|
||||||
t.Fatalf("should be equal to itself")
|
|
||||||
}
|
|
||||||
|
|
||||||
other := &ACL{
|
|
||||||
ID: "guid",
|
|
||||||
Name: "An ACL for testing",
|
|
||||||
Type: "client",
|
|
||||||
Rules: "service \"\" { policy = \"read\" }",
|
|
||||||
RaftIndex: RaftIndex{
|
|
||||||
CreateIndex: 1,
|
|
||||||
ModifyIndex: 2,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
if !acl.IsSame(other) || !other.IsSame(acl) {
|
|
||||||
t.Fatalf("should not care about Raft fields")
|
|
||||||
}
|
|
||||||
|
|
||||||
check := func(twiddle, restore func()) {
|
|
||||||
if !acl.IsSame(other) || !other.IsSame(acl) {
|
|
||||||
t.Fatalf("should be the same")
|
|
||||||
}
|
|
||||||
|
|
||||||
twiddle()
|
|
||||||
if acl.IsSame(other) || other.IsSame(acl) {
|
|
||||||
t.Fatalf("should not be the same")
|
|
||||||
}
|
|
||||||
|
|
||||||
restore()
|
|
||||||
if !acl.IsSame(other) || !other.IsSame(acl) {
|
|
||||||
t.Fatalf("should be the same")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
check(func() { other.ID = "nope" }, func() { other.ID = "guid" })
|
|
||||||
check(func() { other.Name = "nope" }, func() { other.Name = "An ACL for testing" })
|
|
||||||
check(func() { other.Type = "management" }, func() { other.Type = "client" })
|
|
||||||
check(func() { other.Rules = "" }, func() { other.Rules = "service \"\" { policy = \"read\" }" })
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestStructs_ACL_Convert(t *testing.T) {
|
func TestStructs_ACL_Convert(t *testing.T) {
|
||||||
|
|
||||||
acl := &ACL{
|
acl := &ACL{
|
||||||
|
|
Loading…
Reference in a new issue