def test_login_command_simple(gdb_base_fixture, http_expect_request):
    from memfault_gdb import MemfaultLogin, MEMFAULT_CONFIG

    http_expect_request("https://api.memfault.com/auth/me", "GET", None, TEST_AUTH_HEADERS, 200, {})

    login = MemfaultLogin()
    login.invoke("{} {}".format(TEST_EMAIL, TEST_PASSWORD), True)

    assert MEMFAULT_CONFIG.email == TEST_EMAIL
    assert MEMFAULT_CONFIG.password == TEST_PASSWORD
    assert MEMFAULT_CONFIG.organization == None
    assert MEMFAULT_CONFIG.project == None
Exemplo n.º 2
0
def test_login_command_try(gdb_base_fixture, http_expect_request):
    from memfault_gdb import MEMFAULT_CONFIG, MemfaultLogin

    http_expect_request("https://api.try.memfault.com/auth/me", "GET", None,
                        TEST_AUTH_HEADERS, 200, {"id": 123})

    login = MemfaultLogin()
    login.invoke("{} {} --try-me".format(TEST_EMAIL, TEST_PASSWORD), True)

    assert MEMFAULT_CONFIG.email == TEST_EMAIL
    assert MEMFAULT_CONFIG.password == TEST_PASSWORD
    assert MEMFAULT_CONFIG.organization is None
    assert MEMFAULT_CONFIG.project is None
    assert MEMFAULT_CONFIG.api_uri == "https://api.try.memfault.com"
    assert MEMFAULT_CONFIG.ingress_uri == "https://ingress.try.memfault.com"
Exemplo n.º 3
0
def test_login_command_with_all_options(gdb_base_fixture, http_expect_request):
    from memfault_gdb import MEMFAULT_CONFIG, MemfaultLogin

    test_api_uri = "http://dev-api.memfault.com:5000"
    test_ingress_uri = "http://dev-ingress.memfault.com"

    http_expect_request("http://dev-api.memfault.com:5000/auth/me", "GET",
                        None, TEST_AUTH_HEADERS, 200, {"id": 123})

    login = MemfaultLogin()
    login.invoke(
        "{} {} -o {} -p {} --api-uri {} --ingress-uri {}".format(
            TEST_EMAIL, TEST_PASSWORD, TEST_ORG, TEST_PROJECT, test_api_uri,
            test_ingress_uri),
        True,
    )

    assert MEMFAULT_CONFIG.email == TEST_EMAIL
    assert MEMFAULT_CONFIG.password == TEST_PASSWORD
    assert MEMFAULT_CONFIG.organization == TEST_ORG
    assert MEMFAULT_CONFIG.project == TEST_PROJECT
    assert MEMFAULT_CONFIG.api_uri == test_api_uri
    assert MEMFAULT_CONFIG.ingress_uri == test_ingress_uri