def test_parse_url_creds_supersedes_netrc_creds(tmpdir):
    netrc_file = os.path.join(tmpdir.strpath, 'netrc')
    with open(netrc_file, 'w') as f:
        f.write('machine example.org login user1 password pass1\n')
        f.write('machine another.org login user2 password pass2\n')
    string = 'https://*****:*****@example.org,another.org'
    hosts, _, _, _ = parse_elasticsearch_storage(string, netrc_file=netrc_file)
    assert len(hosts) == 2
    assert 'https://*****:*****@example.org' in hosts  # superseded by creds in url
    assert 'https://*****:*****@another.org' in hosts  # got creds from netrc file
def test_parse_url_creds_supersedes_netrc_creds(tmpdir):
    netrc_file = os.path.join(tmpdir.strpath, 'netrc')
    with open(netrc_file, 'w') as f:
        f.write('machine example.org login user1 password pass1\n')
        f.write('machine another.org login user2 password pass2\n')
    string = 'https://*****:*****@example.org,another.org'
    hosts, _, _, _ = parse_elasticsearch_storage(string, netrc_file=netrc_file)
    assert len(hosts) == 2
    assert 'https://*****:*****@example.org' in hosts  # superseded by creds in url
    assert 'https://*****:*****@another.org' in hosts  # got creds from netrc file
def test_parse_with_creds_in_netrc(tmpdir):
    netrc_file = os.path.join(tmpdir.strpath, 'netrc')
    with open(netrc_file, 'w') as f:
        f.write('machine example.org login user1 password pass1\n')
        f.write('machine another.org login user2 password pass2\n')
    string = 'https://example.org,another.org'
    hosts, _, _, _ = parse_elasticsearch_storage(string, netrc_file=netrc_file)
    assert len(hosts) == 2
    assert 'https://*****:*****@example.org' in hosts
    assert 'https://*****:*****@another.org' in hosts
def test_parse_with_creds_in_netrc(tmpdir):
    netrc_file = os.path.join(tmpdir.strpath, 'netrc')
    with open(netrc_file, 'w') as f:
        f.write('machine example.org login user1 password pass1\n')
        f.write('machine another.org login user2 password pass2\n')
    string = 'https://example.org,another.org'
    hosts, _, _, _ = parse_elasticsearch_storage(string, netrc_file=netrc_file)
    assert len(hosts) == 2
    assert 'https://*****:*****@example.org' in hosts
    assert 'https://*****:*****@another.org' in hosts
Beispiel #5
0
def test_parse_elasticsearch_storage():
    benchdir = os.path.basename(os.getcwd())

    assert parse_elasticsearch_storage("http://localhost:9200") == (
        ["http://localhost:9200"], "benchmark", "benchmark", benchdir)
    assert parse_elasticsearch_storage("http://localhost:9200/benchmark2") == (
        ["http://localhost:9200"], "benchmark2", "benchmark", benchdir)
    assert parse_elasticsearch_storage("http://localhost:9200/benchmark2/benchmark2") == (
        ["http://localhost:9200"], "benchmark2", "benchmark2", benchdir)
    assert parse_elasticsearch_storage("http://host1:9200,host2:9200") == (
        ["http://host1:9200", "http://host2:9200"], "benchmark", "benchmark", benchdir)
    assert parse_elasticsearch_storage("http://host1:9200,host2:9200/benchmark2") == (
        ["http://host1:9200", "http://host2:9200"], "benchmark2", "benchmark", benchdir)
    assert parse_elasticsearch_storage("http://localhost:9200/benchmark2/benchmark2?project_name=project_name") == (
        ["http://localhost:9200"], "benchmark2", "benchmark2", "project_name")
Beispiel #6
0
def test_parse_elasticsearch_storage():
    assert parse_elasticsearch_storage("http://localhost:9200") == ([
        "http://localhost:9200"
    ], "benchmark", "benchmark", "pytest-benchmark")
    assert parse_elasticsearch_storage("http://localhost:9200/benchmark2") == (
        ["http://localhost:9200"
         ], "benchmark2", "benchmark", "pytest-benchmark")
    assert parse_elasticsearch_storage(
        "http://localhost:9200/benchmark2/benchmark2") == ([
            "http://localhost:9200"
        ], "benchmark2", "benchmark2", "pytest-benchmark")
    assert parse_elasticsearch_storage("http://host1:9200,host2:9200") == ([
        "http://host1:9200", "http://host2:9200"
    ], "benchmark", "benchmark", "pytest-benchmark")
    assert parse_elasticsearch_storage(
        "http://host1:9200,host2:9200/benchmark2") == ([
            "http://host1:9200", "http://host2:9200"
        ], "benchmark2", "benchmark", "pytest-benchmark")
    assert parse_elasticsearch_storage(
        "http://localhost:9200/benchmark2/benchmark2?project_name=project_name"
    ) == (["http://localhost:9200"], "benchmark2", "benchmark2",
          "project_name")
def test_parse_with_creds_in_second_host_of_url():
    string = 'https://example.org,user:[email protected]'
    hosts, _, _, _ = parse_elasticsearch_storage(string)
    assert len(hosts) == 2
    assert 'https://example.org' in hosts
    assert 'https://*****:*****@another.org' in hosts
def test_parse_with_no_creds():
    string = 'https://example.org,another.org'
    hosts, _, _, _ = parse_elasticsearch_storage(string)
    assert len(hosts) == 2
    assert 'https://example.org' in hosts
    assert 'https://another.org' in hosts
def test_parse_with_creds_in_second_host_of_url():
    string = 'https://example.org,user:[email protected]'
    hosts, _, _, _ = parse_elasticsearch_storage(string)
    assert len(hosts) == 2
    assert 'https://example.org' in hosts
    assert 'https://*****:*****@another.org' in hosts
def test_parse_with_no_creds():
    string = 'https://example.org,another.org'
    hosts, _, _, _ = parse_elasticsearch_storage(string)
    assert len(hosts) == 2
    assert 'https://example.org' in hosts
    assert 'https://another.org' in hosts