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

Skip to content

Commit b16f27f

Browse files
authored
add test cases for Lambda code signing config (#3289)
1 parent 864ae35 commit b16f27f

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

‎localstack/services/awslambda/lambda_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,7 @@ def get_code_signing_config(arn):
17721772
}
17731773
}
17741774

1775-
return Response(json.dumps(result), status=201)
1775+
return Response(json.dumps(result), status=200)
17761776

17771777

17781778
@app.route('/2020-04-22/code-signing-configs/<arn>', methods=['DELETE'])

‎tests/integration/test_lambda.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,71 @@ def test_function_concurrency(self):
646646

647647
testutil.delete_lambda_function(name=function_name)
648648

649+
def test_function_code_singing_config(self):
650+
lambda_client = aws_stack.connect_to_service('lambda')
651+
function_name = 'lambda_func-{}'.format(short_uid())
652+
653+
testutil.create_lambda_function(
654+
handler_file=TEST_LAMBDA_ECHO_FILE,
655+
func_name=function_name,
656+
runtime=LAMBDA_RUNTIME_PYTHON36
657+
)
658+
659+
response = lambda_client.create_code_signing_config(
660+
Description='Testing CodeSigning Config',
661+
AllowedPublishers={
662+
'SigningProfileVersionArns': [
663+
'arn:aws:signer:us-east-1:000000000000:/signing-profiles/test',
664+
]
665+
},
666+
CodeSigningPolicies={
667+
'UntrustedArtifactOnDeployment': 'Enforce'
668+
}
669+
)
670+
671+
self.assertIn('Description', response['CodeSigningConfig'])
672+
self.assertIn('SigningProfileVersionArns', response['CodeSigningConfig']['AllowedPublishers'])
673+
self.assertIn('UntrustedArtifactOnDeployment', response['CodeSigningConfig']['CodeSigningPolicies'])
674+
675+
code_signing_arn = response['CodeSigningConfig']['CodeSigningConfigArn']
676+
response = lambda_client.update_code_signing_config(
677+
CodeSigningConfigArn=code_signing_arn,
678+
CodeSigningPolicies={
679+
'UntrustedArtifactOnDeployment': 'Warn'
680+
}
681+
)
682+
683+
self.assertEqual(response['CodeSigningConfig']['CodeSigningPolicies']['UntrustedArtifactOnDeployment'], 'Warn')
684+
response = lambda_client.get_code_signing_config(
685+
CodeSigningConfigArn=code_signing_arn
686+
)
687+
self.assertEqual(response['ResponseMetadata']['HTTPStatusCode'], 200)
688+
689+
response = lambda_client.put_function_code_signing_config(
690+
CodeSigningConfigArn=code_signing_arn,
691+
FunctionName=function_name
692+
)
693+
self.assertEqual(response['ResponseMetadata']['HTTPStatusCode'], 200)
694+
695+
response = lambda_client.get_function_code_signing_config(
696+
FunctionName=function_name
697+
)
698+
self.assertEqual(response['ResponseMetadata']['HTTPStatusCode'], 200)
699+
self.assertEqual(response['CodeSigningConfigArn'], code_signing_arn)
700+
self.assertEqual(response['FunctionName'], function_name)
701+
702+
response = lambda_client.delete_function_code_signing_config(
703+
FunctionName=function_name
704+
)
705+
self.assertEqual(response['ResponseMetadata']['HTTPStatusCode'], 204)
706+
707+
response = lambda_client.delete_code_signing_config(
708+
CodeSigningConfigArn=code_signing_arn
709+
)
710+
self.assertEqual(response['ResponseMetadata']['HTTPStatusCode'], 204)
711+
712+
testutil.delete_lambda_function(name=function_name)
713+
649714

650715
class TestPythonRuntimes(LambdaTestBase):
651716
@classmethod

0 commit comments

Comments
 (0)