예제 #1
0
 def test_md5_only(self):
     header_value = u"md5={}".format(self.MD5_CHECKSUM)
     response = None
     md5_header = _helpers._parse_checksum_header(header_value,
                                                  response,
                                                  checksum_label="md5")
     assert md5_header == self.MD5_CHECKSUM
     crc32c_header = _helpers._parse_checksum_header(
         header_value, response, checksum_label="crc32c")
     assert crc32c_header is None
예제 #2
0
 def test_empty_value(self):
     header_value = None
     response = None
     md5_header = _helpers._parse_checksum_header(header_value,
                                                  response,
                                                  checksum_label="md5")
     assert md5_header is None
     crc32c_header = _helpers._parse_checksum_header(
         header_value, response, checksum_label="crc32c")
     assert crc32c_header is None
예제 #3
0
 def test_both_crc32c_and_md5(self):
     header_value = u"crc32c={},md5={}".format(self.CRC32C_CHECKSUM,
                                               self.MD5_CHECKSUM)
     response = None
     md5_header = _helpers._parse_checksum_header(header_value,
                                                  response,
                                                  checksum_label="md5")
     assert md5_header == self.MD5_CHECKSUM
     crc32c_header = _helpers._parse_checksum_header(
         header_value, response, checksum_label="crc32c")
     assert crc32c_header == self.CRC32C_CHECKSUM
예제 #4
0
    def test_md5_multiple_matches(self):
        another_checksum = u"eW91IGRpZCBXQVQgbm93Pw=="
        header_value = u"md5={},md5={}".format(self.MD5_CHECKSUM, another_checksum)
        response = mock.sentinel.response

        with pytest.raises(common.InvalidResponse) as exc_info:
            _helpers._parse_checksum_header(
                header_value, response, checksum_label="md5"
            )

        error = exc_info.value
        assert error.response is response
        assert len(error.args) == 3
        assert error.args[1] == header_value
        assert error.args[2] == [self.MD5_CHECKSUM, another_checksum]