當前位置: 首頁>>代碼示例>>C#>>正文


C# SecurityController.Tunnel方法代碼示例

本文整理匯總了C#中Potato.Core.Security.SecurityController.Tunnel方法的典型用法代碼示例。如果您正苦於以下問題:C# SecurityController.Tunnel方法的具體用法?C# SecurityController.Tunnel怎麽用?C# SecurityController.Tunnel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Potato.Core.Security.SecurityController的用法示例。


在下文中一共展示了SecurityController.Tunnel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestSecurityAddGroupDuplicateGroupName

        public void TestSecurityAddGroupDuplicateGroupName() {
            var security = new SecurityController();
            ICommandResult result = security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAddGroup,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName"
                })
            });

            // Test that the group was initially added.
            Assert.AreEqual(security.Groups.Last().Name, "GroupName");

            // Now readd the same group name.
            result = security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAddGroup,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName"
                })
            });

            // Test the second result, make sure it failed.
            Assert.IsFalse(result.Success);
            Assert.AreEqual(result.CommandResultType, CommandResultType.AlreadyExists);
        }
開發者ID:EBassie,項目名稱:Potato,代碼行數:26,代碼來源:TestSecurityGroup.cs

示例2: TestCannotAuthenticateAgainstDifferentTokenId

        public void TestCannotAuthenticateAgainstDifferentTokenId() {
            const string identifier = "192.168.1.1";

            AccessTokenModel accessToken = new AccessTokenModel() {
                Account = new AccountModel() {
                    Username = "Phogue",
                    PasswordHash = "MyPasswordHash"
                }
            };

            var token = accessToken.Generate(identifier);

            var security = new SecurityController();
            security.Tunnel(CommandBuilder.SecurityAddGroup("GroupName").SetOrigin(CommandOrigin.Local));
            security.Tunnel(CommandBuilder.SecurityGroupAddAccount("GroupName", "Phogue").SetOrigin(CommandOrigin.Local));
            security.Tunnel(CommandBuilder.SecurityAccountSetPasswordHash("Phogue", "MyPasswordHash").SetOrigin(CommandOrigin.Local));

            // Now append the token onto the account.
            security.Tunnel(CommandBuilder.SecurityAccountAppendAccessToken("Phogue", accessToken.Id, accessToken.TokenHash, accessToken.LastTouched).SetOrigin(CommandOrigin.Local));

            // Now validate that we can authenticate against the newly appended token hash
            ICommandResult result = security.Tunnel(CommandBuilder.SecurityAccountAuthenticateToken(Guid.NewGuid(), token, identifier).SetOrigin(CommandOrigin.Local));

            Assert.IsFalse(result.Success);
            Assert.AreEqual(CommandResultType.Failed, result.CommandResultType);
        }
開發者ID:EBassie,項目名稱:Potato,代碼行數:26,代碼來源:TestSecurityAccountAuthenticateToken.cs

示例3: TestCheckByAccountUsernameIsIdentical

        public void TestCheckByAccountUsernameIsIdentical() {
            var security = new SecurityController();
            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAddGroup,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName"
                })
            });
            // Now add a user.
            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityGroupAddAccount,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName",
                    "Phogue"
                })
            });

            // Now change the language of the account.
            ICommandResult result = security.DispatchIdentityCheck(new Command() {
                Authentication = {
                    Username = "Phogue"
                }
            }, "Phogue");

            // Make sure it was successful.
            Assert.IsTrue(result.Success);
            Assert.AreEqual(result.CommandResultType, CommandResultType.Success);
        }
開發者ID:EBassie,項目名稱:Potato,代碼行數:30,代碼來源:TestDispatchIdentityCheck.cs

示例4: TestGroupDoesNotExist

        public void TestGroupDoesNotExist() {
            var security = new SecurityController();
            security.Tunnel(CommandBuilder.SecurityAddGroup("ThisIsValid").SetOrigin(CommandOrigin.Local));

            ICommandResult result = security.Tunnel(CommandBuilder.SecurityGroupRemovePermissionTrait("ThisIsNotValid", CommandType.VariablesSet.ToString(), PermissionTraitsType.Boolean).SetOrigin(CommandOrigin.Local));

            Assert.IsFalse(result.Success);
            Assert.AreEqual(CommandResultType.DoesNotExists, result.CommandResultType);
        }
開發者ID:EBassie,項目名稱:Potato,代碼行數:9,代碼來源:TestSecurityGroupRemovePermissionTrait.cs

示例5: TestGroupDoesNotExist

        public void TestGroupDoesNotExist() {
            var security = new SecurityController();
            security.Tunnel(CommandBuilder.SecurityAddGroup("ThisIsValid").SetOrigin(CommandOrigin.Local));

            ICommandResult result = security.Tunnel(CommandBuilder.SecuritySetPredefinedStreamPermissions("ThisIsNotValid").SetOrigin(CommandOrigin.Local));

            Assert.IsFalse(result.Success);
            Assert.AreEqual(CommandResultType.DoesNotExists, result.CommandResultType);
        }
開發者ID:EBassie,項目名稱:Potato,代碼行數:9,代碼來源:TestSecuritySetPredefinedStreamPermissions.cs

示例6: TestEmptyUsername

        public void TestEmptyUsername() {
            var security = new SecurityController();
            security.Tunnel(CommandBuilder.SecurityAddGroup("GroupName").SetOrigin(CommandOrigin.Local));

            // Now add the user.
            ICommandResult result = security.Tunnel(CommandBuilder.SecurityGroupAddAccount("GroupName", String.Empty).SetOrigin(CommandOrigin.Local));

            // Make sure the account was successfully created.
            Assert.IsFalse(result.Success);
            Assert.AreEqual(result.CommandResultType, CommandResultType.InvalidParameter);
        }
開發者ID:EBassie,項目名稱:Potato,代碼行數:11,代碼來源:TestSecurityGroupAddAccount.cs

示例7: TestSuccess

        public void TestSuccess() {
            var security = new SecurityController();

            security.Tunnel(CommandBuilder.SecurityAddGroup("GroupName").SetOrigin(CommandOrigin.Local));

            ICommandResult result = security.Tunnel(CommandBuilder.SecurityGroupAppendPermissionTrait("GroupName", CommandType.VariablesSet.ToString(), PermissionTraitsType.Boolean).SetOrigin(CommandOrigin.Local));

            // Make sure it was not successful.
            Assert.IsTrue(result.Success);
            Assert.AreEqual(CommandResultType.Success, result.CommandResultType);
        }
開發者ID:EBassie,項目名稱:Potato,代碼行數:11,代碼來源:TestSecurityGroupAppendPermissionTrait.cs

示例8: TestSuccess

        public void TestSuccess() {
            var security = new SecurityController();

            security.Tunnel(CommandBuilder.SecurityAddGroup("GroupName").SetOrigin(CommandOrigin.Local));

            ICommandResult result = security.Tunnel(CommandBuilder.SecuritySetPredefinedStreamPermissions("GroupName").SetOrigin(CommandOrigin.Local));

            // Make sure it was not successful.
            Assert.IsTrue(result.Success);
            Assert.AreEqual(CommandResultType.Success, result.CommandResultType);
        }
開發者ID:EBassie,項目名稱:Potato,代碼行數:11,代碼來源:TestSecuritySetPredefinedStreamPermissions.cs

示例9: TestRemoveAccountByLocalSuccess

        public void TestRemoveAccountByLocalSuccess() {
            var security = new SecurityController();
            security.Tunnel(CommandBuilder.SecurityAddGroup("GroupName").SetOrigin(CommandOrigin.Local));
            security.Tunnel(CommandBuilder.SecurityGroupAddAccount("GroupName", "Phogue").SetOrigin(CommandOrigin.Local));

            ICommandResult result = security.Tunnel(CommandBuilder.SecurityRemoveAccount("Phogue").SetOrigin(CommandOrigin.Local));

            // Make sure the command failed. The user cannot remove their own account.
            Assert.IsTrue(result.Success);
            Assert.AreEqual(CommandResultType.Success, result.CommandResultType);
        }
開發者ID:EBassie,項目名稱:Potato,代碼行數:11,代碼來源:TestSecurityRemoveAccount.cs

示例10: TestNoneExpiredNoneRemoved

        public void TestNoneExpiredNoneRemoved() {
            var security = new SecurityController();
            security.Tunnel(CommandBuilder.SecurityAddGroup("GroupName").SetOrigin(CommandOrigin.Local));
            security.Tunnel(CommandBuilder.SecurityGroupAddAccount("GroupName", "Phogue").SetOrigin(CommandOrigin.Local));
            security.Tunnel(CommandBuilder.SecurityAccountAppendAccessToken("Phogue", Guid.NewGuid(), "Token Hash One", DateTime.Now).SetOrigin(CommandOrigin.Local));
            security.Tunnel(CommandBuilder.SecurityAccountAppendAccessToken("Phogue", Guid.NewGuid(), "Token Hash Two", DateTime.Now).SetOrigin(CommandOrigin.Local));

            security.Poke();

            Assert.AreEqual(2, security.Groups.First(group => group.Name == "GroupName").Accounts.First().AccessTokens.Count);
        }
開發者ID:EBassie,項目名稱:Potato,代碼行數:11,代碼來源:TestPoke.cs

示例11: TestPermissionsdescriptionAppended

        public void TestPermissionsdescriptionAppended() {
            var security = new SecurityController();

            security.Tunnel(CommandBuilder.SecurityAddGroup("GroupName").SetOrigin(CommandOrigin.Local));

            security.Tunnel(CommandBuilder.SecurityGroupSetPermissionDescription("GroupName", CommandType.VariablesSet.ToString(), "Description!").SetOrigin(CommandOrigin.Local));

            var group = security.Groups.First(item => item.Name == "GroupName");

            Assert.AreEqual("Description!", group.Permissions.First(permission => permission.CommandType == CommandType.VariablesSet).Description);
        }
開發者ID:EBassie,項目名稱:Potato,代碼行數:11,代碼來源:TestSecurityGroupSetPermissionDescription.cs

示例12: TestTwoExpiredTwoRemoved

        public void TestTwoExpiredTwoRemoved() {
            var security = new SecurityController();
            security.Tunnel(CommandBuilder.SecurityAddGroup("GroupName").SetOrigin(CommandOrigin.Local));
            security.Tunnel(CommandBuilder.SecurityGroupAddAccount("GroupName", "Phogue").SetOrigin(CommandOrigin.Local));
            security.Tunnel(CommandBuilder.SecurityAccountAppendAccessToken("Phogue", Guid.NewGuid(), "Token Hash One", DateTime.Now.AddDays(-3)).SetOrigin(CommandOrigin.Local));
            security.Tunnel(CommandBuilder.SecurityAccountAppendAccessToken("Phogue", Guid.NewGuid(), "Token Hash Two", DateTime.Now.AddDays(-3)).SetOrigin(CommandOrigin.Local));

            security.Poke();

            Assert.IsEmpty(security.Groups.First(group => group.Name == "GroupName").Accounts.First().AccessTokens);
        }
開發者ID:EBassie,項目名稱:Potato,代碼行數:11,代碼來源:TestPoke.cs

示例13: TestPermissionsTraitAppended

        public void TestPermissionsTraitAppended() {
            var security = new SecurityController();

            security.Tunnel(CommandBuilder.SecurityAddGroup("GroupName").SetOrigin(CommandOrigin.Local));

            security.Tunnel(CommandBuilder.SecurityGroupAppendPermissionTrait("GroupName", CommandType.VariablesSet.ToString(), PermissionTraitsType.Boolean).SetOrigin(CommandOrigin.Local));

            var group = security.Groups.First(item => item.Name == "GroupName");

            Assert.AreEqual(new List<String>() { PermissionTraitsType.Boolean }, group.Permissions.First(permission => permission.CommandType == CommandType.VariablesSet).Traits);
        }
開發者ID:EBassie,項目名稱:Potato,代碼行數:11,代碼來源:TestSecurityGroupAppendPermissionTrait.cs

示例14: TestAddSuccess

        public void TestAddSuccess() {
            var security = new SecurityController();
            security.Tunnel(CommandBuilder.SecurityAddGroup("GroupName").SetOrigin(CommandOrigin.Local));

            // Now add the user.
            ICommandResult result = security.Tunnel(CommandBuilder.SecurityGroupAddAccount("GroupName", "Phogue").SetOrigin(CommandOrigin.Local));

            // Make sure the account was successfully created.
            Assert.IsTrue(result.Success);
            Assert.AreEqual(result.CommandResultType, CommandResultType.Success);
            Assert.AreEqual(security.Groups.SelectMany(group => group.Accounts).First().Username, "Phogue");
        }
開發者ID:EBassie,項目名稱:Potato,代碼行數:12,代碼來源:TestSecurityGroupAddAccount.cs

示例15: TestEmptyUidFailure

        public void TestEmptyUidFailure() {
            var security = new SecurityController();
            security.Tunnel(CommandBuilder.SecurityAddGroup("GroupName").SetOrigin(CommandOrigin.Local));
            security.Tunnel(CommandBuilder.SecurityGroupAddAccount("GroupName", "Phogue").SetOrigin(CommandOrigin.Local));

            // Now add a player to the "Phogue" account.
            ICommandResult result = security.Tunnel(CommandBuilder.SecurityAccountAddPlayer("Phogue", CommonProtocolType.DiceBattlefield3, String.Empty).SetOrigin(CommandOrigin.Local));

            // Validate the player was added successfully.
            Assert.IsFalse(result.Success);
            Assert.AreEqual(result.CommandResultType, CommandResultType.InvalidParameter);
        }
開發者ID:EBassie,項目名稱:Potato,代碼行數:12,代碼來源:TestSecurityAccountAddPlayer.cs


注:本文中的Potato.Core.Security.SecurityController.Tunnel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。