Esempio n. 1
0
        public void TestAddConstrainedKey()
        {
            var agentClient = new TestAgentClient();

            agentClient.Agent.ConfirmUserPermissionCallback = delegate
            {
                return(true);
            };
            Agent.KeyConstraint        constraint;
            List <Agent.KeyConstraint> constraints = new List <Agent.KeyConstraint>();

            constraint      = new Agent.KeyConstraint();
            constraint.Type = Agent.KeyConstraintType.SSH_AGENT_CONSTRAIN_CONFIRM;
            constraints.Add(constraint);
            agentClient.AddKey(rsaKey, constraints);
            Assert.That(agentClient.Agent.KeyCount, Is.EqualTo(1));
            Assert.That(agentClient.Agent.GetAllKeys().First().Constraints.Count,
                        Is.EqualTo(1));
            Assert.That(agentClient.Agent.GetAllKeys().First().Constraints.First().Type,
                        Is.EqualTo(Agent.KeyConstraintType.SSH_AGENT_CONSTRAIN_CONFIRM));

            constraint      = new Agent.KeyConstraint();
            constraint.Type = Agent.KeyConstraintType.SSH_AGENT_CONSTRAIN_LIFETIME;
            constraint.Data = (uint)10;
            constraints.Clear();
            constraints.Add(constraint);
            agentClient.AddKey(rsaKey, constraints);
            Assert.That(agentClient.Agent.KeyCount, Is.EqualTo(1));
            Assert.That(agentClient.Agent.GetAllKeys().First().Constraints.Count,
                        Is.EqualTo(1));
            Assert.That(agentClient.Agent.GetAllKeys().First().Constraints.First().Type,
                        Is.EqualTo(Agent.KeyConstraintType.SSH_AGENT_CONSTRAIN_LIFETIME));
        }
Esempio n. 2
0
        public void TestAddKey()
        {
            var agentClient = new TestAgentClient();
            int keyCount    = 0;

            foreach (var key in allKeys)
            {
                agentClient.AddKey(key);
                keyCount += 1;
                Assert.That(agentClient.Agent.KeyCount, Is.EqualTo(keyCount));
                Assert.That(agentClient.Agent.GetAllKeys()
                            .Get(key.Version, key.GetPublicKeyBlob()), Is.Not.Null);
            }
        }
Esempio n. 3
0
        public void TestAddKey()
        {
            var agentClient = new TestAgentClient();
              int keyCount = 0;

              foreach (var key in allKeys) {
            agentClient.AddKey(key);
            keyCount += 1;
            Assert.That(agentClient.Agent.KeyCount, Is.EqualTo(keyCount));
            Assert.That(agentClient.Agent.GetAllKeys()
               .Get(key.Version, key.GetPublicKeyBlob()), Is.Not.Null);
              }
        }
Esempio n. 4
0
        public void TestAddConstrainedKey()
        {
            var agentClient = new TestAgentClient();
              agentClient.Agent.ConfirmUserPermissionCallback = delegate
              {
            return true;
              };
              Agent.KeyConstraint constraint;
              List<Agent.KeyConstraint> constraints = new List<Agent.KeyConstraint>();

              constraint = new Agent.KeyConstraint();
              constraint.Type = Agent.KeyConstraintType.SSH_AGENT_CONSTRAIN_CONFIRM;
              constraints.Add(constraint);
              agentClient.AddKey(rsaKey, constraints);
              Assert.That(agentClient.Agent.KeyCount, Is.EqualTo(1));
              Assert.That(agentClient.Agent.GetAllKeys().First().Constraints.Count,
            Is.EqualTo(1));
              Assert.That(agentClient.Agent.GetAllKeys().First().Constraints.First().Type,
            Is.EqualTo(Agent.KeyConstraintType.SSH_AGENT_CONSTRAIN_CONFIRM));

              constraint = new Agent.KeyConstraint();
              constraint.Type = Agent.KeyConstraintType.SSH_AGENT_CONSTRAIN_LIFETIME;
              constraint.Data = (uint)10;
              constraints.Clear();
              constraints.Add(constraint);
              agentClient.AddKey(rsaKey, constraints);
              Assert.That(agentClient.Agent.KeyCount, Is.EqualTo(1));
              Assert.That(agentClient.Agent.GetAllKeys().First().Constraints.Count,
            Is.EqualTo(1));
              Assert.That(agentClient.Agent.GetAllKeys().First().Constraints.First().Type,
            Is.EqualTo(Agent.KeyConstraintType.SSH_AGENT_CONSTRAIN_LIFETIME));
        }