mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 03:52:02 +02:00
Dummy AWS credentials for Route53 tests to prevent outbound connections (#6456)
Boto3 / botocore library has a feature that tries to fetch AWS credentials from IAM if a set of credentials isn't available otherwise. This happens when boto loops through different credential providers in order to find the keys. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=912103 This PR simply adds dummy environmental variables for the tests that will be picked up by the credential provider iterator in order to prevent making outbound connections. * Hardcode dummy AWS credentials to prevent boto3 making outgoing connections * Remove the dummy credentials when tearing down test case
This commit is contained in:
committed by
Brad Warren
parent
1d783fd4b9
commit
a1af42bc5f
@@ -1,5 +1,6 @@
|
||||
"""Tests for certbot_dns_route53.dns_route53.Authenticator"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
@@ -20,8 +21,18 @@ class AuthenticatorTest(unittest.TestCase, dns_test_common.BaseAuthenticatorTest
|
||||
|
||||
self.config = mock.MagicMock()
|
||||
|
||||
# Set up dummy credentials for testing
|
||||
os.environ["AWS_ACCESS_KEY_ID"] = "dummy_access_key"
|
||||
os.environ["AWS_SECRET_ACCESS_KEY"] = "dummy_secret_access_key"
|
||||
|
||||
self.auth = Authenticator(self.config, "route53")
|
||||
|
||||
def tearDown(self):
|
||||
# Remove the dummy credentials from env vars
|
||||
del os.environ["AWS_ACCESS_KEY_ID"]
|
||||
del os.environ["AWS_SECRET_ACCESS_KEY"]
|
||||
super(AuthenticatorTest, self).tearDown()
|
||||
|
||||
def test_perform(self):
|
||||
self.auth._change_txt_record = mock.MagicMock()
|
||||
self.auth._wait_for_change = mock.MagicMock()
|
||||
@@ -117,8 +128,18 @@ class ClientTest(unittest.TestCase):
|
||||
|
||||
self.config = mock.MagicMock()
|
||||
|
||||
# Set up dummy credentials for testing
|
||||
os.environ["AWS_ACCESS_KEY_ID"] = "dummy_access_key"
|
||||
os.environ["AWS_SECRET_ACCESS_KEY"] = "dummy_secret_access_key"
|
||||
|
||||
self.client = Authenticator(self.config, "route53")
|
||||
|
||||
def tearDown(self):
|
||||
# Remove the dummy credentials from env vars
|
||||
del os.environ["AWS_ACCESS_KEY_ID"]
|
||||
del os.environ["AWS_SECRET_ACCESS_KEY"]
|
||||
super(ClientTest, self).tearDown()
|
||||
|
||||
def test_find_zone_id_for_domain(self):
|
||||
self.client.r53.get_paginator = mock.MagicMock()
|
||||
self.client.r53.get_paginator().paginate.return_value = [
|
||||
|
||||
Reference in New Issue
Block a user