AssertionError

Error message != ['AccessDenied'] search by Google

args : tuple
("Error message != ['AccessDenied']",)

Traceback

  1. /usr/local/lib/python3.7/unittest/case.py in testPartExecutor (arguments )

    self : _Outcome
    <unittest.case._Outcome object at 0x7fe3fd621090>
    test_case : Policy
    test_grant_object_access_to_specific_ip_address (c2tests.s3.policy.Policy)
    isTest : bool
    True
    1. @contextlib.contextmanager
    2. def testPartExecutor(self, test_case, isTest=False):
    3. old_success = self.success
    4. self.success = True
    5. try:
    6. yield
    7. except KeyboardInterrupt:
    8. raise
    9. except SkipTest as e:
    10. self.success = False

    Locals

    exc_info : NoneType
    None
    old_success : bool
    True

    Globals

    __unittest : bool
    True
    _subtest_msg_sentinel : object
    <object object at 0x7fe415310fc0>
    DIFF_OMITTED : str
    Diff is %s characters long. Set self.maxDiff to None to see it.
  2. /usr/local/lib/python3.7/unittest/case.py in run (arguments )

    self : Policy
    test_grant_object_access_to_specific_ip_address (c2tests.s3.policy.Policy)
    result : DiagnosticsTestResult
    <xmlrunner.extra.diagnosticstestrunner.DiagnosticsTestResult run=1 errors=0 failures=0>
    1. with outcome.testPartExecutor(self):
    2. self.setUp()
    3. if outcome.success:
    4. outcome.expecting_failure = expecting_failure
    5. with outcome.testPartExecutor(self, isTest=True):
    6. testMethod()
    7. outcome.expecting_failure = False
    8. with outcome.testPartExecutor(self):
    9. self.tearDown()

    Locals

    expecting_failure : bool
    False
    expecting_failure_class : bool
    False
    expecting_failure_method : bool
    False
    orig_result : DiagnosticsTestResult
    <xmlrunner.extra.diagnosticstestrunner.DiagnosticsTestResult run=1 errors=0 failures=0>
    outcome : _Outcome
    <unittest.case._Outcome object at 0x7fe3fd621090>
    testMethod : method
    <bound method Policy.test_grant_object_access_to_specific_ip_address of <c2tests.s3.policy.Policy testMethod=test_grant_object_access_to_specific_ip_address>>

    Globals

    __unittest : bool
    True
    _subtest_msg_sentinel : object
    <object object at 0x7fe415310fc0>
    DIFF_OMITTED : str
    Diff is %s characters long. Set self.maxDiff to None to see it.
  3. /root/c2tests/.venv/lib/python3.7/site-packages/c2tests/s3/policy.py in test_grant_object_access_to_specific_ip_address (arguments )

    self : Policy
    test_grant_object_access_to_specific_ip_address (c2tests.s3.policy.Policy)
    1. self.assert_error("403", self.s3client.head_bucket, Bucket=bucket)
    2. self.assert_error(
    3. "AccessDenied",
    4. self.upload_random_file, bucket, OBJECT_NAME, 10
    5. )
    6. self.assert_error("AccessDenied", self.s3client.list_objects, Bucket=bucket)
    7. try:
    8. response = requests.get(PUBLIC_IP_SERVICE_URL, verify=False)
    9. response.raise_for_status()

    Locals

    bucket : str
    test-3afb01d3-fe6a-49fe-b796-239aa5dccd00
    policy : dict
    {'Version': '2012-10-17', 'Statement': [{'Effect': 'Allow', 'Sid': 'TestSpecificIpPolicy', 'Principal': '*', 'Action': ['s3:PutObject', 's3:GetObject', 's3:DeleteObject'], 'Resource': 'arn:aws:s3:::test-3afb01d3-fe6a-49fe-b796-239aa5dccd00/*', 'Condition': {'IpAddress': {'aws:SourceIp': '0.0.0.0'}}}, {'Effect': 'Allow', 'Sid': 'AddPerm', 'Principal': '*', 'Action': ['s3:ListBucket'], 'Resource': 'arn:aws:s3:::test-3afb01d3-fe6a-49fe-b796-239aa5dccd00', 'Condition': {'IpAddress': {'aws:SourceIp': '0.0.0.0'}}}]}
    wrong_public_ip : str
    0.0.0.0

    Globals

    OBJECT_NAME : str
    object_name
    P2_PROJECT : str
    p2
    PRIVATE_PREFIX : str
    private
    PUBLIC_IP_SERVICE_URL : str
    https://api.ipify.org/?format=text
    PUBLIC_PREFIX : str
    public
  4. /root/c2tests/.venv/lib/python3.7/site-packages/c2tests/__init__.py in assert_error (arguments )

    self : Policy
    test_grant_object_access_to_specific_ip_address (c2tests.s3.policy.Policy)
    error_codes : list
    ['AccessDenied']
    func : method
    <bound method ClientCreator._create_api_method.<locals>._api_call of <botocore.client.S3 object at 0x7fe3fe63cdd0>>
    *args : tuple
    ()
    **kwargs : dict
    {'Bucket': 'test-3afb01d3-fe6a-49fe-b796-239aa5dccd00'}
    1. error_code = e.response["Error"]["Code"]
    2. if error_code in error_codes:
    3. return
    4. else:
    5. raise self.failureException(
    6. "Error message {0} != {1}".format(error_code, error_codes)
    7. )
    8. else:
    9. raise self.failureException("{0} not raised".format(error_codes))

    Locals

    error_code : str
     

    Globals

    gethostbyname : builtin_function_or_method
    <built-in function gethostbyname>
    UNSIGNED : UNSIGNED
    <botocore.UNSIGNED object at 0x7fe407aa0ed0>

Environment

Time of report generation
2024-02-23 01:35:53
Python version
3.7.9 (default, Sep 21 2022, 19:11:27) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
Path to executable
/root/c2tests/.venv/bin/python
Working directory
/root/c2tests
Arguments vector
  1. /root/c2tests/.venv/bin/c2tests
  2. run
  3. -s
  4. ec2
  5. s3
  6. vpc