parent
2b37a60f65
commit
7b06d74576
@ -355,7 +355,7 @@ class ELBV2Response(BaseResponse):
|
|||||||
def modify_rule(self):
|
def modify_rule(self):
|
||||||
rule_arn = self._get_param("RuleArn")
|
rule_arn = self._get_param("RuleArn")
|
||||||
params = self._get_params()
|
params = self._get_params()
|
||||||
conditions = params["Conditions"]
|
conditions = params.get("Conditions", [])
|
||||||
actions = params.get("Actions", [])
|
actions = params.get("Actions", [])
|
||||||
rules = self.elbv2_backend.modify_rule(
|
rules = self.elbv2_backend.modify_rule(
|
||||||
rule_arn=rule_arn, conditions=conditions, actions=actions
|
rule_arn=rule_arn, conditions=conditions, actions=actions
|
||||||
|
@ -632,6 +632,64 @@ def test_create_rule_priority_in_use():
|
|||||||
err["Message"].should.equal("The specified priority is in use.")
|
err["Message"].should.equal("The specified priority is in use.")
|
||||||
|
|
||||||
|
|
||||||
|
@mock_elbv2
|
||||||
|
@mock_ec2
|
||||||
|
def test_modify_rule_conditions():
|
||||||
|
response, _, _, _, _, elbv2 = create_load_balancer()
|
||||||
|
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
||||||
|
|
||||||
|
action = {
|
||||||
|
"Type": "redirect",
|
||||||
|
"RedirectConfig": {
|
||||||
|
"Protocol": "HTTPS",
|
||||||
|
"Port": "443",
|
||||||
|
"StatusCode": "HTTP_301",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
condition = {
|
||||||
|
"Field": "path-pattern",
|
||||||
|
"PathPatternConfig": {"Values": [f"/sth*",]},
|
||||||
|
}
|
||||||
|
|
||||||
|
response = elbv2.create_listener(
|
||||||
|
LoadBalancerArn=load_balancer_arn,
|
||||||
|
Protocol="HTTP",
|
||||||
|
Port=80,
|
||||||
|
DefaultActions=[action],
|
||||||
|
)
|
||||||
|
http_listener_arn = response.get("Listeners")[0]["ListenerArn"]
|
||||||
|
|
||||||
|
response = elbv2.create_rule(
|
||||||
|
ListenerArn=http_listener_arn, Priority=100, Conditions=[], Actions=[],
|
||||||
|
)
|
||||||
|
rule = response["Rules"][0]
|
||||||
|
|
||||||
|
assert len(rule["Actions"]) == 0
|
||||||
|
assert len(rule["Conditions"]) == 0
|
||||||
|
|
||||||
|
response = elbv2.modify_rule(RuleArn=rule["RuleArn"], Actions=[action],)
|
||||||
|
rule = response["Rules"][0]
|
||||||
|
|
||||||
|
assert len(rule["Actions"]) == 1
|
||||||
|
assert len(rule["Conditions"]) == 0
|
||||||
|
|
||||||
|
response = elbv2.modify_rule(RuleArn=rule["RuleArn"], Conditions=[condition])
|
||||||
|
rule = response["Rules"][0]
|
||||||
|
|
||||||
|
assert len(rule["Actions"]) == 1
|
||||||
|
assert len(rule["Conditions"]) == 1
|
||||||
|
|
||||||
|
response = elbv2.modify_rule(
|
||||||
|
RuleArn=rule["RuleArn"],
|
||||||
|
Conditions=[condition, condition],
|
||||||
|
Actions=[action, action],
|
||||||
|
)
|
||||||
|
rule = response["Rules"][0]
|
||||||
|
|
||||||
|
assert len(rule["Actions"]) == 2
|
||||||
|
assert len(rule["Conditions"]) == 2
|
||||||
|
|
||||||
|
|
||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_handle_listener_rules():
|
def test_handle_listener_rules():
|
||||||
|
Loading…
Reference in New Issue
Block a user