Github user sanju1010 commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1401#discussion_r52417314
  
    --- Diff: test/integration/component/test_escalations_instances.py ---
    @@ -2068,6 +2068,94 @@ def test_13_vm_nics(self):
                     "VM NIC is not same as expected"
                 )
             return
    +    @attr(tags=["advanced", "basic"], required_hardware="true")
    +    def test_14_Create_vm_with_same_sshkey(self):
    +        """
    +        @Desc: Test to verify API call Register ssh key pair fails when 
uses same public key for differnet key name
    +        """
    +
    +
    +        # Listing all the SSH Key pairs
    +        list_keypairs_before = SSHKeyPair.list(
    +            self.userapiclient
    +        )
    +        list_keypairs_before_size = 0
    +        if list_keypairs_before is not None:
    +            list_keypairs_before_size = len(list_keypairs_before)
    +
    +        # Registering first Key pair
    +        new_keypair1 = SSHKeyPair.register(
    +            self.userapiclient,
    +            name="keypair1",
    +            publickey="ssh-rsa: 
e6:9a:1e:b5:98:75:88:5d:56:bc:92:7b:43:48:05:b2")
    +        self.assertIsNotNone(
    +            new_keypair1,
    +            "New Key pair generation failed"
    +        )
    +        self.assertEquals(
    +            "keypair1",
    +            new_keypair1.name,
    +            "Key Pair not created with given name"
    +        )
    +        # Listing all the SSH Key pairs again
    +        list_keypairs_after = SSHKeyPair.list(
    +            self.userapiclient
    +        )
    +        status = validateList(list_keypairs_after)
    +        self.assertEquals(
    +            PASS,
    +            status[0],
    +            "Listing of Key pairs failed"
    +        )
    +        # Verifying that list size is increased by 1
    +        self.assertEquals(
    +            list_keypairs_before_size + 1,
    +            len(list_keypairs_after),
    +            "List count is not matching"
    +        )
    +        try:
    +
    +            # Registering second key pair using same public key
    +            new_keypair2 = SSHKeyPair.register(
    +                self.userapiclient,
    +                name="keypair2",
    +                publickey="ssh-rsa: 
e6:9a:1e:b5:98:75:88:5d:56:bc:92:7b:43:48:05:b2")
    +            self.fail("SSH Key creation passed using same public key ")
    +        except CloudstackAPIException  as e:
    +            self.assertRaises("Exception Raised : %s" % e)
    --- End diff --
    
    Replace self.assertRaises to execute the test completely.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to