Beispiel #1
0
 def set_allowed_hosts(self):
     """ First operation will fail and the second operation will succeed"""
     allowedhosts = "[\"*.couchbase.com\",\"10.112.0.0/16\",\"172.23.0.0/16\"]"
     host = "[\"*.couchbase.com\"]"
     for node in self.cluster.nodes_in_cluster:
         shell = RemoteMachineShellConnection(node)
         output = shell.set_allowedhosts("localhost", self.cluster.master.rest_username,
                                         self.cluster.master.rest_password, host)
         self.log.info("expected failure from set_allowedhosts {0}".format(output))
         if "errors" not in output[0]:
             self.fail("Invalid address should fail, address {0}".format(host))
         output = shell.set_allowedhosts("localhost", self.cluster.master.rest_username,
                                         self.cluster.master.rest_password, allowedhosts)
         if len(output) > 2:
             self.fail("Allowed hosts is not changed and error is {0}".format(output))
         output = shell.get_allowedhosts(self.cluster.master.rest_username,
                                         self.cluster.master.rest_password)
         self.assertEqual(output, allowedhosts)
         shell.disconnect()
Beispiel #2
0
 def test_allowed_hosts_rest_apis(self):
     self.__create_user("user1", "password", "data_writer[*]:admin")
     self.__create_user("user2", "password", "data_writer[*]", False)
     for node in self.cluster.nodes_in_cluster:
         shell = RemoteMachineShellConnection(node)
         for user in self.users_list:
             if user["Writer"]:
                 output = shell.set_allowedhosts("localhost", user["name"],
                                                 user["password"],
                                                 self.allowedhosts)
                 if len(output[0]) > 2:
                     self.fail(
                         "Allowed hosts is not changed and error is {0}".
                         format(output))
                 output = shell.get_allowedhosts(user["name"],
                                                 user["password"])
                 self.assertEqual(output, self.allowedhosts)
         shell.disconnect()
     self.add_node_and_rebalance()