示例#1
0
def test_upstream_good(app):
    payload = '''
services:
  - name: my-service
    tags: ["ns.mytest", "another"]
    host: myservice
'''
    y = yaml.load(payload, Loader=yaml.FullLoader)
    validate_upstream(y, {}, [])
示例#2
0
def test_upstream_protected_service_allow(app):
    payload = '''
services:
  - name: my-service
    tags: ["ns.mytest", "another"]
    host: myapi.my-namespace.svc
'''
    y = yaml.load(payload, Loader=yaml.FullLoader)
    validate_upstream(y, {"perm-protected-ns": ["allow"]}, ['my-namespace'])
示例#3
0
def test_upstream_valid_service(app):
    payload = '''
services:
  - name: my-service
    tags: ["ns.mytest", "another"]
    host: myapi.my-namespace.svc
'''
    y = yaml.load(payload, Loader=yaml.FullLoader)
    validate_upstream(y, {"perm-project": ["ns.mytest"]}, [])
示例#4
0
def test_upstream_protected_service(app):
    payload = '''
services:
  - name: my-service
    tags: ["ns.mytest", "another"]
    host: myapi.my-namespace.svc
'''
    y = yaml.load(payload, Loader=yaml.FullLoader)
    with pytest.raises(Exception, match=r"service upstream is invalid \(e3\)"):
        validate_upstream(y, {}, ['my-namespace'])
示例#5
0
def test_upstream_url(app):
    payload = '''
services:
  - name: my-service
    tags: ["ns.mytest", "another"]
    url: http://localhost:4000
'''
    y = yaml.load(payload, Loader=yaml.FullLoader)
    with pytest.raises(Exception, match=r"service upstream is invalid \(e1\)"):
        validate_upstream(y, {"perm-project": ["ns.mytest"]}, [])
示例#6
0
def test_upstream_localhost(app):
    payload = '''
services:
  - name: my-service
    tags: ["ns.mytest", "another"]
    host: localhost
'''
    y = yaml.load(payload, Loader=yaml.FullLoader)
    with pytest.raises(Exception, match=r"service upstream is invalid \(e1\)"):
        validate_upstream(y, {}, [])