Ejemplo n.º 1
0
def main():
    """Run authentification hook."""
    # get authentication data
    with open(
            os.path.dirname(__file__) + os.path.normcase('/strato-auth.json'),
            encoding='UTF-8',
    ) as file:
        auth = json.load(file)
        username = auth.get('username')
        password = auth.get('password')
        totp_secret = auth.get('totp_secret')
        totp_devicename = auth.get('totp_devicename')
        waiting_time = auth.get('waiting_time', 0)

    strato = CertbotStratoApi()
    if not strato.login(username, password, totp_secret, totp_devicename):
        print('ERROR: Strato login not accepted.')
        sys.exit(1)
    # Requests package id which package contains domain to be verified
    strato.get_package_id()
    # Requests all current TXT/CNAME/SPF/DKIM records from Strato
    strato.get_txt_records()
    # Add verification token record
    strato.set_amce_record()
    # Sets all TXT/CNAME/SPF/DKIM records with AMCE record in dns server
    strato.push_txt_records()
    # Sleep to give the DNS Server time to get ready
    time.sleep(waiting_time)
Ejemplo n.º 2
0
def test_get_package_id(test_input, expected, requests_mock):
    project_page = open('test/projectPage.html', 'r').read()
    os.environ['CERTBOT_DOMAIN'] = test_input
    os.environ['CERTBOT_VALIDATION'] = 'xyz'
    strato = CertbotStratoApi()
    requests_mock.get(strato.api_url, text=project_page)

    strato.get_package_id()

    assert strato.package_id == expected