def test_create_3072_key(): # create a test parameter provider = DSAKeyProvider() name = "/test/parameter-%s" % uuid.uuid4() request = Request("Create", name) request["ResourceProperties"]["Description"] = "A large private key" request["ResourceProperties"]["KeySize"] = "3072" response = provider.handle(request, {}) assert response["Status"] == "SUCCESS", response["Reason"] assert provider.is_valid_cfn_response(), response["Reason"] assert "PhysicalResourceId" in response physical_resource_id = response["PhysicalResourceId"] assert "Data" in response assert "Arn" in response["Data"] assert "PublicKey" in response["Data"] assert "PublicKeyPEM" in response["Data"] assert "Hash" in response["Data"] assert response["Data"]["Arn"] == physical_resource_id assert (response["Data"]["Hash"] == hashlib.md5( response["Data"]["PublicKey"].encode("ascii")).hexdigest()) public_key = load_pem_public_key( response["Data"]["PublicKeyPEM"].encode("ascii"), backend=default_backend()) assert public_key.key_size == 3072 # delete the parameter request = Request("Delete", name, physical_resource_id) response = handler(request, {}) assert response["Status"] == "SUCCESS", response["Reason"]
def test_create_3072_key(): # create a test parameter provider = DSAKeyProvider() name = '/test/parameter-%s' % uuid.uuid4() request = Request('Create', name) request['ResourceProperties']['Description'] = 'A large private key' request['ResourceProperties']['KeySize'] = '3072' response = provider.handle(request, {}) assert response['Status'] == 'SUCCESS', response['Reason'] assert provider.is_valid_cfn_response(), response['Reason'] assert 'PhysicalResourceId' in response physical_resource_id = response['PhysicalResourceId'] assert 'Data' in response assert 'Arn' in response['Data'] assert 'PublicKey' in response['Data'] assert 'PublicKeyPEM' in response['Data'] assert 'Hash' in response['Data'] assert response['Data']['Arn'] == physical_resource_id assert response['Data']['Hash'] == hashlib.md5(response['Data']['PublicKey'].encode('ascii')).hexdigest() public_key = load_pem_public_key(response['Data']['PublicKeyPEM'].encode('ascii'), backend=default_backend()) assert public_key.key_size == 3072 # delete the parameter request = Request('Delete', name, physical_resource_id) response = handler(request, {}) assert response['Status'] == 'SUCCESS', response['Reason']
def test_defaults(): request = Request("Create", "abc") r = DSAKeyProvider() r.set_request(request, {}) assert r.is_valid_request() assert r.get("KeyAlias") == "alias/aws/ssm" assert r.get("Description") == ""
def test_defaults(): request = Request('Create', 'abc') r = DSAKeyProvider() r.set_request(request, {}) assert r.is_valid_request() assert r.get('KeyAlias') == 'alias/aws/ssm' assert r.get('Description') == ''
def test_type_convert(): request = Request("Create", "abc") request["ResourceProperties"]["RefreshOnUpdate"] = "true" r = DSAKeyProvider() r.set_request(request, {}) assert r.is_valid_request() assert isinstance(r.get("RefreshOnUpdate"), bool)
def test_type_convert(): request = Request('Create', 'abc') request['ResourceProperties']['RefreshOnUpdate'] = 'true' r = DSAKeyProvider() r.set_request(request, {}) assert r.is_valid_request() assert isinstance(r.get('RefreshOnUpdate'), bool)
def test_create(): # create a test parameter provider = DSAKeyProvider() name = '/test/parameter-%s' % uuid.uuid4() request = Request('Create', name) request['ResourceProperties']['Description'] = 'A ppretty private key' response = provider.handle(request, {}) assert response['Status'] == 'SUCCESS', response['Reason'] assert provider.is_valid_cfn_response(), response['Reason'] assert 'PhysicalResourceId' in response physical_resource_id = response['PhysicalResourceId'] assert 'Data' in response assert 'Arn' in response['Data'] assert 'PublicKey' in response['Data'] assert 'Hash' in response['Data'] assert 'Version' in response['Data'] assert response['Data']['Arn'] == physical_resource_id assert response['Data']['Hash'] == hashlib.md5( response['Data']['PublicKey']).hexdigest() assert response['Data']['Version'] == 1 public_key = load_pem_public_key(response['Data']['PublicKeyPEM'], backend=default_backend()) assert public_key.key_size == 2048 request['RequestType'] = 'Update' request['ResourceProperties']['RefreshOnUpdate'] = True request['PhysicalResourceId'] = physical_resource_id response = provider.handle(request, {}) assert response['Status'] == 'SUCCESS', response['Reason'] assert response['Data']['Hash'] == hashlib.md5( response['Data']['PublicKey']).hexdigest() assert response['Data']['Version'] == 2 # delete the parameters request = Request('Delete', name, physical_resource_id) response = handler(request, {}) assert response['Status'] == 'SUCCESS', response['Reason']