Thanks to visit codestin.com
Credit goes to github.com

Skip to content

test: added test cases for code lambda signing config #3289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion localstack/services/awslambda/lambda_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,7 @@ def get_code_signing_config(arn):
}
}

return Response(json.dumps(result), status=201)
return Response(json.dumps(result), status=200)


@app.route('/2020-04-22/code-signing-configs/<arn>', methods=['DELETE'])
Expand Down
65 changes: 65 additions & 0 deletions tests/integration/test_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,71 @@ def test_function_concurrency(self):

testutil.delete_lambda_function(name=function_name)

def test_function_code_singing_config(self):
lambda_client = aws_stack.connect_to_service('lambda')
function_name = 'lambda_func-{}'.format(short_uid())

testutil.create_lambda_function(
handler_file=TEST_LAMBDA_ECHO_FILE,
func_name=function_name,
runtime=LAMBDA_RUNTIME_PYTHON36
)

response = lambda_client.create_code_signing_config(
Description='Testing CodeSigning Config',
AllowedPublishers={
'SigningProfileVersionArns': [
'arn:aws:signer:us-east-1:000000000000:/signing-profiles/test',
]
},
CodeSigningPolicies={
'UntrustedArtifactOnDeployment': 'Enforce'
}
)

self.assertIn('Description', response['CodeSigningConfig'])
self.assertIn('SigningProfileVersionArns', response['CodeSigningConfig']['AllowedPublishers'])
self.assertIn('UntrustedArtifactOnDeployment', response['CodeSigningConfig']['CodeSigningPolicies'])

code_signing_arn = response['CodeSigningConfig']['CodeSigningConfigArn']
response = lambda_client.update_code_signing_config(
CodeSigningConfigArn=code_signing_arn,
CodeSigningPolicies={
'UntrustedArtifactOnDeployment': 'Warn'
}
)

self.assertEqual(response['CodeSigningConfig']['CodeSigningPolicies']['UntrustedArtifactOnDeployment'], 'Warn')
response = lambda_client.get_code_signing_config(
CodeSigningConfigArn=code_signing_arn
)
self.assertEqual(response['ResponseMetadata']['HTTPStatusCode'], 200)

response = lambda_client.put_function_code_signing_config(
CodeSigningConfigArn=code_signing_arn,
FunctionName=function_name
)
self.assertEqual(response['ResponseMetadata']['HTTPStatusCode'], 200)

response = lambda_client.get_function_code_signing_config(
FunctionName=function_name
)
self.assertEqual(response['ResponseMetadata']['HTTPStatusCode'], 200)
self.assertEqual(response['CodeSigningConfigArn'], code_signing_arn)
self.assertEqual(response['FunctionName'], function_name)

response = lambda_client.delete_function_code_signing_config(
FunctionName=function_name
)
self.assertEqual(response['ResponseMetadata']['HTTPStatusCode'], 204)

response = lambda_client.delete_code_signing_config(
CodeSigningConfigArn=code_signing_arn
)
self.assertEqual(response['ResponseMetadata']['HTTPStatusCode'], 204)

testutil.delete_lambda_function(name=function_name)


class TestPythonRuntimes(LambdaTestBase):
@classmethod
Expand Down