Пример #1
0
def test_create_http_host_match():
    name = "0"
    condition = Condition(name, conditions['http_host'])
    data = condition.data

    assert condition.name == "0"
    assert not condition.partition
    assert data.get('httpHost')
    assert data.get('host')
    assert data.get('equals')
    assert data.get('values') == ["www.my-site.com", "www.your-site.com"]

    assert not data.get('startsWith')
    assert not data.get('endsWith')
    assert not data.get('contains')

    assert 'httpUri' not in data
    assert 'httpCookie' not in data
    assert 'httpHeader' not in data

    assert not data.get('index')
    assert not data.get('path')
    assert not data.get('pathSegment')
    assert not data.get('extension')
    assert not data.get('httpCookie')
    assert not data.get('httpHeader')
    assert not data.get('tmName')
Пример #2
0
def test_create_http_header_match():
    name = "0"
    condition = Condition(name, conditions['http_header'])
    data = condition.data

    assert condition.name == "0"
    assert not condition.partition

    assert data.get('httpHeader')
    assert data.get('tmName') == "Host"
    assert data.get('values') == ["www.acme.com"]

    assert 'httpHost' not in data
    assert 'httpUri' not in data
    assert 'httpCookie' not in data

    assert not data.get('equals')
    assert not data.get('startsWith')
    assert not data.get('endsWith')
    assert data.get('contains')

    assert not data.get('missing')
    assert not data.get('not')
    assert not data.get('caseSensitive')

    assert not data.get('index')
    assert not data.get('path')
    assert not data.get('pathSegment')
Пример #3
0
def test_create_tcp_address_match():
    name = "0"
    condition = Condition(name, conditions['tcp_address'])
    data = condition.data

    assert condition.name == "0"
    assert not condition.partition

    assert data.get('tcp')
    assert data.get('values') == ["10.0.0.0/16", "10.10.10.10/32"]

    assert 'httpHost' not in data
    assert 'httpUri' not in data
    assert 'httpCookie' not in data

    assert not data.get('equals')
    assert not data.get('startsWith')
    assert not data.get('endsWith')
    assert data.get('matches')

    assert not data.get('missing')
    assert not data.get('not')
    assert not data.get('caseSensitive')

    assert not data.get('index')
    assert not data.get('path')
    assert not data.get('pathSegment')
Пример #4
0
def test_create_http_uri_path_segment_match():
    name = "0"
    condition = Condition(name, conditions['http_uri_path_segment'])
    data = condition.data

    assert condition.name == "0"
    assert not condition.partition

    assert data.get('httpUri')
    assert data.get('pathSegment')
    assert data.get('values') == ["articles"]
    assert data.get('index') == 2

    assert 'httpHost' not in data
    assert 'httpCookie' not in data
    assert 'httpHeader' not in data

    assert not data.get('equals')
    assert data.get('startsWith')
    assert not data.get('endsWith')
    assert not data.get('contains')

    assert not data.get('missing')
    assert not data.get('not')
    assert not data.get('caseSensitive')

    assert not data.get('path')
    assert not data.get('extension')
    assert not data.get('httpCookie')
    assert not data.get('httpHeader')
    assert not data.get('tmName')
Пример #5
0
def test_equal_conditions():
    name = "0"
    condition_1 = Condition(name, conditions['http_host'])
    condition_2 = Condition(name, conditions['http_host'])

    assert id(condition_1) != id(condition_2)
    assert condition_1 == condition_2

    condition_1.data['values'].pop()

    assert not condition_1 == condition_2
    assert condition_1 != condition_2

    fake_condition = {"httpHost": False, "values": ["www.my-site.com"]}

    assert condition_1 != fake_condition
    assert condition_1 != conditions['http_uri_path']
Пример #6
0
def test_uri_path(bigip):
    name = "0"
    condition = Condition(name, conditions['http_host'])

    with pytest.raises(NotImplementedError):
        condition._uri_path(bigip)
Пример #7
0
def test_str_condition():
    name = "0"
    condition = Condition(name, conditions['http_host'])

    assert str(condition)
Пример #8
0
def test_create_http_unsupported_operand_type():
    name = "0"
    with pytest.raises(ValueError):
        Condition(name, conditions['http_unsupported_operand_type'])
Пример #9
0
def test_create_http_uri_unsupported_match():
    name = "0"

    with pytest.raises(ValueError):
        Condition(name, conditions['http_uri_unsupported'])
Пример #10
0
def test_uri_path(bigip):
    name="0"
    condition = Condition(name, conditions['http_host'])

    with pytest.raises(NotImplementedError):
        condition._uri_path(bigip)