Ejemplo n.º 1
0
 def config(self):
     config = mock.create_autospec(Configuration([]), spec_set=True)
     config.ingress_suffixes = ["svc.test.example.com", "127.0.0.1.xip.io"]
     config.host_rewrite_rules = [
         HostRewriteRule("rewrite.example.com=test.rewrite.example.com"),
         HostRewriteRule(r"([a-z0-9](?:[-a-z0-9]*[a-z0-9])?).rewrite.example.com=test.\1.rewrite.example.com")
     ]
     return config
 def config(self):
     config = mock.create_autospec(Configuration([]), spec_set=True)
     config.ingress_suffixes = ["svc.test.example.com", "127.0.0.1.xip.io"]
     config.host_rewrite_rules = [
         HostRewriteRule("rewrite.example.com=test.rewrite.example.com"),
         HostRewriteRule(
             r"([a-z0-9](?:[-a-z0-9]*[a-z0-9])?).rewrite.example.com=test.\1.rewrite.example.com"
         )
     ]
     config.tls_certificate_issuer_type_default = DEFAULT_TLS_ISSUER
     config.tls_certificate_issuer_type_overrides = {}
     return config
 def test_host_rewrite_rules(self):
     args = ("pattern=value", r"(\d+)\.\example\.com=$1.example.net",
             "www.([a-z]+.com)={env}.$1")
     config = Configuration(
         ["--host-rewrite-rule=%s" % arg for arg in args])
     assert config.host_rewrite_rules == [
         HostRewriteRule(arg) for arg in args
     ]
 def test_host_rewrite_rules_from_file(self, tmpdir):
     args = ("pattern=value", r"(\d+)\.\example\.com=$1.example.net",
             "www.([a-z]+.com)={env}.$1")
     config_file = tmpdir.join("config.yaml")
     with config_file.open("w") as fobj:
         pyaml.dump({"host-rewrite-rule": args},
                    fobj,
                    safe=True,
                    default_style='"')
     config = Configuration(["--config-file", config_file.strpath])
     assert config.host_rewrite_rules == [
         HostRewriteRule(arg) for arg in args
     ]
 def test_apply(self, rule, host, result):
     hrr = HostRewriteRule(rule)
     assert hrr.matches(host)
     assert not hrr.matches("something-else")
     assert hrr.apply(host) == result
 def test_equality(self):
     arg = "pattern=value"
     assert HostRewriteRule(arg) == HostRewriteRule(arg)