コード例 #1
0
        public void ToStringTest()
        {
            var acl1 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = null,
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = null,
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };
            var acl2 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = null,
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = null,
                    Host           = "\"h1\"",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };
            var aclFilter1 = new AclBindingFilter
            {
                PatternFilter = new ResourcePatternFilter
                {
                    Type = ResourceType.Topic,
                    Name = null,
                    ResourcePatternType = ResourcePatternType.Literal
                },
                EntryFilter = new AccessControlEntryFilter
                {
                    Principal      = null,
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };

            var expectedString1 = @"{""Pattern"": {""Type"": ""Topic"", ""Name"": null, ""ResourcePatternType"": ""Literal""}, ""Entry"": {""Principal"": null, ""Host"": ""h1"", ""Operation"": ""All"", ""PermissionType"": ""Allow""}}";
            var expectedString2 = @"{""Pattern"": {""Type"": ""Topic"", ""Name"": null, ""ResourcePatternType"": ""Literal""}, ""Entry"": {""Principal"": null, ""Host"": ""\""h1\"""", ""Operation"": ""All"", ""PermissionType"": ""Allow""}}";

            Assert.Equal(expectedString1, acl1.ToString());
            Assert.NotEqual(acl1.ToString(), aclFilter1.ToString());
            Assert.NotEqual(acl1.ToString(), acl2.ToString());
            Assert.Equal(expectedString2, acl2.ToString());
        }
コード例 #2
0
        public void Equality()
        {
            var acl1 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = null,
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = null,
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };
            var acl2 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = "a1",
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = "p1",
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };

            var rep1 = new DescribeAclsReport {
            };
            var rep2 = new DescribeAclsReport {
            };
            var rep3 = new DescribeAclsReport
            {
                Error = new Error(ErrorCode.NoError, "Success", false),
            };
            var rep4 = new DescribeAclsReport
            {
                Error       = new Error(ErrorCode.NoError, "Success", false),
                AclBindings = new List <AclBinding>
                {
                    acl1,
                    acl2
                }
            };
            var rep5 = new DescribeAclsReport
            {
                Error       = rep4.Error,
                AclBindings = rep4.AclBindings
            };
            var rep6 = new DescribeAclsReport
            {
                Error       = new Error(ErrorCode.NoError, "Other message", false),
                AclBindings = new List <AclBinding>
                {
                    acl1.Clone(),
                acl2.Clone()
                }
            };
            var rep7 = new DescribeAclsReport
            {
                Error       = new Error(ErrorCode.NoError, "Success", true),
                AclBindings = new List <AclBinding>
                {
                    acl1.Clone(),
                acl2.Clone()
                }
            };

            Assert.Equal(rep1, rep2);
            Assert.True(rep1 == rep2);
            Assert.NotEqual(rep1, rep3);
            Assert.False(rep1 == rep3);
            Assert.NotEqual(rep3, rep4);
            Assert.True(rep3 != rep4);
            Assert.Equal(rep4, rep5);
            Assert.True(rep4 == rep5);
            Assert.Equal(rep4, rep6);
            Assert.True(rep4 == rep6);
            Assert.NotEqual(rep6, rep7);
            Assert.True(rep6 != rep7);
        }
コード例 #3
0
        public void Equality()
        {
            var acl1 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = null,
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = null,
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };
            var acl2 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = "a1",
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = "p1",
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };
            var acl3 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = "a2",
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = "p1",
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };

            var ex1 = new DeleteAclsException(new List <DeleteAclsReport>());
            var ex2 = new DeleteAclsException(new List <DeleteAclsReport>
            {
                new DeleteAclsReport()
                {
                    Error       = new Error(ErrorCode.NoError, "Success", false),
                    AclBindings = new List <AclBinding>
                    {
                        acl1,
                        acl2
                    }
                }
            });
            var ex3 = new DeleteAclsException(new List <DeleteAclsReport>
            {
                new DeleteAclsReport()
                {
                    Error       = new Error(ErrorCode.NoError, "Other message", false),
                    AclBindings = new List <AclBinding>
                    {
                        acl2.Clone(),
                        acl1.Clone(),
                        acl1.Clone(),
                    }
                }
            });
            var ex4 = new DeleteAclsException(new List <DeleteAclsReport>
            {
                new DeleteAclsReport()
                {
                    Error       = new Error(ErrorCode.NoError, "Other message", false),
                    AclBindings = new List <AclBinding>
                    {
                        acl1.Clone(),
                        acl2.Clone(),
                        acl3.Clone(),
                    }
                }
            });

            Assert.NotEqual(ex1, ex2);
            Assert.True(ex1 != ex2);
            Assert.Equal(ex2, ex3);
            Assert.True(ex2 == ex3);
            Assert.NotEqual(ex3, ex4);
            Assert.True(ex3 != ex4);
        }
コード例 #4
0
        public void Equality()
        {
            var acl1 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = null,
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = null,
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };
            var acl2 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = "a1",
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = "p1",
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };

            var res1 = new DescribeAclsResult {
            };
            var res2 = new DescribeAclsResult {
            };
            var res3 = new DescribeAclsResult
            {
                AclBindings = new List <AclBinding>
                {
                    acl1,
                    acl2
                }
            };
            var res4 = new DescribeAclsResult
            {
                AclBindings = res3.AclBindings
            };
            var res5 = new DescribeAclsResult
            {
                AclBindings = new List <AclBinding>
                {
                    acl1.Clone(),
                acl2.Clone()
                }
            };

            Assert.Equal(res1, res2);
            Assert.True(res1 == res2);
            Assert.Equal(res3, res4);
            Assert.True(res3 == res4);
            Assert.Equal(res3, res5);
            Assert.True(res3 == res5);
        }
コード例 #5
0
        public void Equality()
        {
            var acl1 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = null,
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = null,
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };
            var acl2 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = "a1",
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = "p1",
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };
            var acl3 = new AclBinding {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = "a1",
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = "p1",
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };
            var acl4 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Unknown,
                    Name = null,
                    ResourcePatternType = ResourcePatternType.Unknown
                },
                Entry = new AccessControlEntry
                {
                    Principal      = null,
                    Host           = null,
                    Operation      = AclOperation.Unknown,
                    PermissionType = AclPermissionType.Unknown
                }
            };
            var aclF1 = new AclBindingFilter
            {
                PatternFilter = new ResourcePatternFilter
                {
                    Type = ResourceType.Topic,
                    Name = "a1",
                    ResourcePatternType = ResourcePatternType.Literal
                },
                EntryFilter = new AccessControlEntryFilter
                {
                    Principal      = "p1",
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };
            var aclF2 = new AclBindingFilter
            {
                PatternFilter = new ResourcePatternFilter
                {
                    Type = ResourceType.Topic,
                    Name = "a1",
                    ResourcePatternType = ResourcePatternType.Literal
                },
                EntryFilter = new AccessControlEntryFilter
                {
                    Principal      = "p1",
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };

            Assert.NotEqual(acl1, acl2);
            Assert.NotEqual(acl2, acl1);
            Assert.Equal(acl2, acl3);
            Assert.True(acl1 != acl2);
            Assert.True(acl2 != acl1);
            Assert.True(acl2 == acl3);
            Assert.NotEqual(acl4, acl1);
            Assert.NotEqual(acl4, acl2);
            Assert.Equal(acl4, acl4);
            Assert.True(acl4 != acl1);
            Assert.True(acl4 != acl2);
            Assert.False(acl4 == acl1);
            Assert.False(acl4 == acl2);
            Assert.Equal(aclF1, aclF2);
            Assert.True(aclF1 == aclF2);
            Assert.False(aclF1 != aclF2);
        }