def test_head_no_layout_id():
    """Test HEAD api without layout id, it should return response as "None"."""
    config = CORTXS3Config()
    response = CORTXS3ObjectApi(config).head("test_oid1", None)
    if (response is not None):
        assert response[0] is False
        assert response[1] is None
def test_delete_no_oid():
    """Test DELETE api without index, it should return response as "None"."""
    config = CORTXS3Config()
    response = CORTXS3ObjectApi(config).delete(None, "test_layot_id2")
    if (response is not None):
        assert response[0] is False
        assert response[1] is None
Пример #3
0
def test_put_no_index():
    """Test PUT api with no index should return response as "None"."""
    config = CORTXS3Config()
    response = CORTXS3ObjectApi(config, CONNECTION_TYPE_PRODUCER).put(
        None, "test_value2")
    if (response is not None):
        assert response[0] is False
def test_delete_no_layout_id():
    """Test DELETE api without layout id, it should return response as "None"."""
    config = CORTXS3Config()
    response = CORTXS3ObjectApi(config).delete("test_oid1", None, "test_pvid_str")
    if (response is not None):
        assert response[0] is False
        assert response[1] is None
def test_get_no_oid():
    """Test GET api without oid should return response as "None"."""
    config = CORTXS3Config()
    response = CORTXS3ObjectApi(config).get(None)
    if (response is not None):
        assert response[0] is False
        assert response[1] is None
def test_head_no_oid():
    """Test HEAD api without index, it should return response as "None"."""
    config = CORTXS3Config(use_cipher=False)
    response = CORTXS3ObjectApi(config).head(None, "test_layot_id2")
    if (response is not None):
        assert response[0] is False
        assert response[1] is None
Пример #7
0
 def __init__(self,
              config,
              probable_delete_records,
              logger=None,
              objectapi=None,
              kvapi=None,
              indexapi=None):
     """Initialise Validator"""
     self.config = config
     self.current_obj_in_VersionList = None
     self.probable_delete_records = probable_delete_records
     if (logger is None):
         self._logger = logging.getLogger("ObjectRecoveryValidator")
     else:
         self._logger = logger
     if (objectapi is None):
         self._objectapi = CORTXS3ObjectApi(self.config,
                                            logger=self._logger)
     else:
         self._objectapi = objectapi
     if (kvapi is None):
         self._kvapi = CORTXS3KVApi(self.config, logger=self._logger)
     else:
         self._kvapi = kvapi
     if (indexapi is None):
         self._indexapi = CORTXS3IndexApi(self.config, logger=self._logger)
     else:
         self._indexapi = indexapi
Пример #8
0
def test_head_no_oid():
    """Test HEAD api without index, it should return response as "None"."""
    config = CORTXS3Config()
    response = CORTXS3ObjectApi(config, CONNECTION_TYPE_PRODUCER).head(
        None, "test_layot_id2")
    if (response is not None):
        assert response[0] is False
        assert response[1] is None
Пример #9
0
def test_delete_no_pvid():
    """Test DELETE api without pvid, it should return response as "None"."""
    config = CORTXS3Config()
    response = CORTXS3ObjectApi(config, CONNECTION_TYPE_PRODUCER).delete(
        "test_oid1", "test_layout_id2", None)
    if (response is not None):
        assert response[0] is False
        assert response[1] is None
Пример #10
0
def perform_head_object(oid_dict):
    print("Validating non-existence of oids using HEAD object api")
    print("Probable dead list should not contain :" + str(list(oid_dict.keys())))
    config = CORTXS3Config()
    for oid,layout_id in oid_dict.items():
        response = CORTXS3ObjectApi(config).head(oid, layout_id)
        assert response is not None
        assert response[0] is False
        assert isinstance(response[1], CORTXS3ErrorResponse)
        assert response[1].get_error_status() == 404
        assert response[1].get_error_reason() == "Not Found"
        print("Object oid \"" + oid + "\" is not present in list..")
    print("HEAD object validation completed..")
def test_head_success():
    """Test HEAD api, it should send success response."""
    httpconnection = Mock(spec=HTTPConnection)
    httpresponse = Mock(spec=HTTPResponse)
    httpresponse.status = 200
    httpresponse.getheaders.return_value = \
        'Content-Type:text/html;Content-Length:14'
    httpresponse.read.return_value = b'{}'
    httpresponse.reason = ''
    httpconnection.getresponse.return_value = httpresponse

    config = CORTXS3Config()
    response = CORTXS3ObjectApi(config, connection=httpconnection).head("test_oid1", "test_layout_id1")
    if (response is not None):
        assert response[0] is True
def test_head_failure():
    """Test if HEAD api fails, it should return error response."""
    httpconnection = Mock(spec=HTTPConnection)
    httpresponse = Mock(spec=HTTPResponse)
    httpresponse.status = 404
    httpresponse.getheaders.return_value = \
        'Content-Type:text/html;Content-Length:14'
    httpresponse.read.return_value = b'{}'
    httpresponse.reason = 'NOT FOUND'
    httpconnection.getresponse.return_value = httpresponse

    config = CORTXS3Config()
    response = CORTXS3ObjectApi(config, connection=httpconnection).head("test_oid2", "test_layout_id2")
    if (response is not None):
        assert response[0] is False
def test_put_failure():
    """Test if PUT fails it should return error response."""
    httpconnection = Mock(spec=HTTPConnection)
    httpresponse = Mock(spec=HTTPResponse)
    httpresponse.status = 409
    httpresponse.getheaders.return_value = \
        'Content-Type:text/html;Content-Length:14'
    httpresponse.read.return_value = b'{}'
    httpresponse.reason = 'CONFLICT'
    httpconnection.getresponse.return_value = httpresponse

    config = CORTXS3Config()
    response = CORTXS3ObjectApi(config, connection=httpconnection).put("test_index2", "test_value2")
    if (response is not None):
        assert response[0] is False
def test_put_success():
    """Test PUT api, it should send success response."""
    httpconnection = Mock(spec=HTTPConnection)
    httpresponse = Mock(spec=HTTPResponse)
    httpresponse.status = 201
    httpresponse.getheaders.return_value = \
        'Content-Type:text/html;Content-Length:14'
    httpresponse.read.return_value = b'{}'
    httpresponse.reason = 'CREATED'
    httpconnection.getresponse.return_value = httpresponse

    config = CORTXS3Config()
    response = CORTXS3ObjectApi(config, connection=httpconnection).put("test_index1", "test_value1")
    if (response is not None):
        assert response[0] is True
def test_get_failure():
    """Test if GET api fails it should return error response"""
    httpconnection = Mock(spec=HTTPConnection)
    httpresponse = Mock(spec=HTTPResponse)
    httpresponse.status = 404
    httpresponse.getheaders.return_value = \
        'Content-Type:text/html;Content-Length:14'
    httpresponse.read.return_value = b'{}'
    httpresponse.reason = 'NOT FOUND'
    httpconnection.getresponse.return_value = httpresponse

    config = CORTXS3Config(use_cipher=False)
    response = CORTXS3ObjectApi(config,
                                connection=httpconnection).get("test_index2")
    if (response is not None):
        assert response[0] is False
def test_delete_success():
    """Test DELETE api, it should send success response."""
    httpconnection = Mock(spec=HTTPConnection)
    httpresponse = Mock(spec=HTTPResponse)
    httpresponse.status = 204
    httpresponse.getheaders.return_value = \
        'Content-Type:text/html;Content-Length:14'
    httpresponse.read.return_value = b'{}'
    httpresponse.reason = 'NO CONTENT'
    httpconnection.getresponse.return_value = httpresponse

    config = CORTXS3Config(use_cipher=False)
    response = CORTXS3ObjectApi(config, connection=httpconnection).delete(
        "test_oid1", "test_layout_id1")
    if (response is not None):
        assert response[0] is True
def test_get_success():
    """Test GET api, it should return success response."""
    result = b'{"test_obj1": "{ \"obj-name\" : \"test_bucket_1/test_obj1\"}"}'

    httpconnection = Mock(spec=HTTPConnection)
    httpresponse = Mock(spec=HTTPResponse)
    httpresponse.status = 200
    httpresponse.getheaders.return_value = \
        'Content-Type:text/html;Content-Length:14'
    httpresponse.read.return_value = result
    httpresponse.reason = 'OK'
    httpconnection.getresponse.return_value = httpresponse

    config = CORTXS3Config()
    response = CORTXS3ObjectApi(config, connection=httpconnection).get("test_object1")
    if (response is not None):
        assert response[0] is True
def test_put_no_index():
    """Test PUT api with no index should return response as "None"."""
    config = CORTXS3Config(use_cipher=False)
    response = CORTXS3ObjectApi(config).put(None, "test_value2")
    if (response is not None):
        assert response[0] is False