File tree Expand file tree Collapse file tree 6 files changed +10
-14
lines changed
localstack-core/localstack/services/apigateway
tests/aws/services/apigateway Expand file tree Collapse file tree 6 files changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -86,8 +86,10 @@ class ApiGatewayStore(BaseStore):
86
86
# maps resource ARN to tags
87
87
TAGS : Dict [str , Dict [str , str ]] = CrossRegionAttribute (default = dict )
88
88
89
- # internal deployments, represents a frozen REST API for a deployment
90
- internal_deployments : dict [str , RestApiDeployment ] = LocalAttribute (default = dict )
89
+ # internal deployments, represents a frozen REST API for a deployment, used in our router
90
+ # TODO: make sure API ID are unique across all accounts
91
+ # maps ApiID + deploymentId to a RestApiDeployment, an executable/snapshot of a REST API
92
+ internal_deployments : dict [(str , str ), RestApiDeployment ] = CrossAccountAttribute (default = dict )
91
93
92
94
# active deployments, mapping API ID + Stage to deployment ID
93
95
# TODO: make sure API ID are unique across all accounts
Original file line number Diff line number Diff line change 6
6
7
7
8
8
class RestApiGateway (Gateway ):
9
- # TODO: not sure we need to extend it, might remove if not needed
10
9
def __init__ (self ):
11
10
super ().__init__ (context_class = RestApiInvocationContext )
12
11
self .request_handlers .extend (
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ def populate_rest_api_invocation_context(
48
48
):
49
49
try :
50
50
deployment_id = self ._global_store .active_deployments [(api_id , stage )]
51
- frozen_deployment = self ._global_store .internal_deployments [deployment_id ]
51
+ frozen_deployment = self ._global_store .internal_deployments [( api_id , deployment_id ) ]
52
52
53
53
except KeyError :
54
54
# TODO: find proper error when trying to hit an API with no deployment/stage linked
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ def create_deployment(
106
106
moto_rest_api = moto_rest_api ,
107
107
localstack_rest_api = rest_api_container ,
108
108
)
109
- store .internal_deployments [deployment ["id" ]] = frozen_deployment
109
+ store .internal_deployments [( rest_api_id , deployment ["id" ]) ] = frozen_deployment
110
110
111
111
if stage_name :
112
112
store .active_deployments [(rest_api_id , stage_name )] = deployment ["id" ]
@@ -118,4 +118,4 @@ def delete_deployment(
118
118
) -> None :
119
119
call_moto (context )
120
120
store = get_apigateway_store (context = context )
121
- store .internal_deployments .pop (deployment_id , None )
121
+ store .internal_deployments .pop (( rest_api_id , deployment_id ) , None )
Original file line number Diff line number Diff line change @@ -970,24 +970,20 @@ def update_method_response(
970
970
@handler ("CreateStage" , expand = False )
971
971
def create_stage (self , context : RequestContext , request : CreateStageRequest ) -> Stage :
972
972
call_moto (context )
973
- rest_api_id = request ["restApiId" ]
974
- stage_name = request ["stageName" ]
975
- moto_api = get_moto_rest_api (context , rest_api_id = rest_api_id )
976
- stage = moto_api .stages .get (stage_name )
973
+ moto_api = get_moto_rest_api (context , rest_api_id = request ["restApiId" ])
974
+ stage = moto_api .stages .get (request ["stageName" ])
977
975
if not stage :
978
976
raise NotFoundException ("Invalid Stage identifier specified" )
979
977
980
978
if not hasattr (stage , "documentation_version" ):
981
979
stage .documentation_version = request .get ("documentationVersion" )
982
980
983
981
# make sure we update the stage_name on the deployment entity in moto
984
- deployment_id = request ["deploymentId" ]
985
- deployment = moto_api .deployments .get (deployment_id )
982
+ deployment = moto_api .deployments .get (request ["deploymentId" ])
986
983
deployment .stage_name = stage .name
987
984
988
985
response = stage .to_json ()
989
986
self ._patch_stage_response (response )
990
-
991
987
return response
992
988
993
989
def get_stage (
Original file line number Diff line number Diff line change @@ -309,7 +309,6 @@ def test_api_gateway_lambda_integration_aws_type(
309
309
310
310
url = api_invoke_url (api_id , stage = stage , path = "/test" )
311
311
response = requests .post (url , json = {"test" : "test" })
312
- print (response .content )
313
312
314
313
assert response .headers ["Content-Type" ] == "text/html"
315
314
assert response .headers ["Access-Control-Allow-Origin" ] == "*"
You can’t perform that action at this time.
0 commit comments