コード例 #1
0
        public void TestLockUnlock()
        {
            var passphrase  = Encoding.UTF8.GetBytes("passphrase");
            var agentClient = new TestAgentClient();

            /* verify that locking works */
            Assert.That(() => agentClient.Lock(passphrase),
                        Throws.Nothing);

            /* verify that locking already locked agent fails */
            Assert.That(() => agentClient.Lock(passphrase),
                        Throws.Exception.TypeOf <AgentFailureException>());

            /* verify that unlocking works */
            Assert.That(() => agentClient.Unlock(passphrase),
                        Throws.Nothing);

            /* verify that unlocking already unlocked agent fails */
            Assert.That(() => agentClient.Unlock(passphrase),
                        Throws.Exception.TypeOf <AgentFailureException>());

            /* try with null passphrase */
            Assert.That(() => agentClient.Lock(null),
                        Throws.Nothing);
            Assert.That(() => agentClient.Unlock(null),
                        Throws.Nothing);

            /* verify that bad passphrase fails */
            Assert.That(() => agentClient.Lock(passphrase),
                        Throws.Nothing);
            Assert.That(() => agentClient.Unlock(null),
                        Throws.Exception.TypeOf <AgentFailureException>());
        }
コード例 #2
0
ファイル: AgentClientTest.cs プロジェクト: dlech/SshAgentLib
        public void TestLockUnlock()
        {
            var passphrase = Encoding.UTF8.GetBytes("passphrase");
              var agentClient = new TestAgentClient();

              /* verify that locking works */
              Assert.That(() => agentClient.Lock(passphrase),
            Throws.Nothing);

              /* verify that locking already locked agent fails */
              Assert.That(() => agentClient.Lock(passphrase),
            Throws.Exception.TypeOf<AgentFailureException>());

              /* verify that unlocking works */
              Assert.That(() => agentClient.Unlock(passphrase),
            Throws.Nothing);

              /* verify that unlocking already unlocked agent fails */
              Assert.That(() => agentClient.Unlock(passphrase),
            Throws.Exception.TypeOf<AgentFailureException>());

              /* try with null passphrase */
              Assert.That(() => agentClient.Lock(null),
            Throws.Nothing);
              Assert.That(() => agentClient.Unlock(null),
            Throws.Nothing);

              /* verify that bad passphrase fails */
              Assert.That(() => agentClient.Lock(passphrase),
            Throws.Nothing);
              Assert.That(() => agentClient.Unlock(null),
            Throws.Exception.TypeOf<AgentFailureException>());
        }