Exemplo n.º 1
0
    def test_setSecurity(self):

        self.client.put(self.buildKey(1), "test_value_1")

        acl = common.ACL(identity=100)
        domain = common.Domain(roles=[common.Roles.READ])
        acl.domains = [domain]

        if self.adminClient.use_ssl:
            self.adminClient.setSecurity([acl])

            # Verify user 100 can only read
            read_only_client = Client(self.host, self.port, identity=100)
            read_only_client.get(self.buildKey(1))  # Should be OK.
            args = (self.buildKey(2), 'test_value_2')
            self.assertRaises(KineticMessageException, read_only_client.put,
                              *args)
        else:
            try:
                #TODO: change this to self.assertRaises
                self.adminClient.setSecurity([acl])
            except KineticException:
                pass
            else:
                self.fail('Exception should be thrown if not using SSL')
Exemplo n.º 2
0
 def setUp(self):
     self.test_dir = tempfile.mkdtemp()
     self.ports = self.PORTS
     self._sim_map = {}
     try:
         self._sim_map = start_simulators(_find_kinetic_jar(KINETIC_JAR),
                                          self.test_dir, *self.ports)
         self.client_map = {}
         for port in self.ports:
             self.client_map[port] = Client('localhost', port)
     except Exception:
         self.tearDown()
Exemplo n.º 3
0
    def test_setSecurity(self):

        self.client.put(self.buildKey(1), "test_value_1")

        acl = common.ACL(identity=100)
        domain = common.Domain(roles=[common.Roles.READ])
        acl.domains = [domain]

        self.adminClient.setSecurity([acl])

        # Verify user 100 can only read
        read_only_client = Client(self.host, self.port, identity=100)
        read_only_client.get(self.buildKey(1))  # Should be OK.
        args = (self.buildKey(2), 'test_value_2')
        self.assertRaises(KineticMessageException, read_only_client.put, *args)
Exemplo n.º 4
0
    def setUpClass(cls):
        cls.client = None
        cls.baseKey = "tests/py/%s/" % cls.__name__

        cls.port = int(KINETIC_PORT)
        cls.host = KINETIC_HOST
        cls.jar_path = _find_kinetic_jar(KINETIC_JAR)
        cls.datadir = None
        cls.simulator = None
        cls.stdout = cls.stderr = None
        try:
            backoff = 0.1
            while True:
                sock = socket.socket()
                try:
                    sock.connect((cls.host, cls.port))
                except socket.error:
                    if backoff > 2:
                        raise
                else:
                    # k, we can connect
                    sock.close()
                    break
                cls._check_simulator()
                time.sleep(backoff)
                backoff *= 2  # double it!
        except:
            if hasattr(cls, 'stdout'):
                try:
                    raise SimulatorRuntimeError(cls.stdout, cls.stderr,
                                                cls.simulator.returncode)
                except:
                    # this is some dodgy shit to setup the re-raise at the bottom
                    pass
            cls.tearDownClass()
            raise

        cls.client = Client(cls.host, cls.port)
        cls.client.connect()
Exemplo n.º 5
0
 def setUp(self):
     super(KineticBasicTestCase, self).setUp()
     self.client = Client(self.host, self.port)
     self.client.connect()
Exemplo n.º 6
0
 def setUp(self):
     super(BatchTestCase, self).setUp()
     self.client = Client(self.host, self.port)
     self.client.connect()
     self._create_new_batch()