def test_401_with_invalid_credentials(client): headers = Headers() headers.set('Authorization', basic_auth_encode('invalid-username', 'invalid-password')) response = client.get('/user', headers=headers) assert response.status_code == 401 assert response.json.get('error') == 'invalid_token'
def test_200_with_credentials(client, test_user): headers = Headers() headers.set('Authorization', basic_auth_encode('*****@*****.**', 'secret123')) response = client.get('/user', headers=headers) assert response.status_code == 200 assert response.json.get('user') == test_user.id
def test_200_with_credentials(client): headers = Headers() headers.set("Authorization", basic_auth_encode("*****@*****.**", "secret123")) response = client.get("/secrets", headers=headers) assert response.status_code == 200 assert isinstance(response.json.get("secrets"), list)
def test_200_with_credentials(client): headers = Headers() headers.set('Authorization', basic_auth_encode('*****@*****.**', 'secret123')) response = client.get('/secrets', headers=headers) assert response.status_code == 200 assert isinstance(response.json.get('secrets'), list)
def test_200_with_credentials(client, test_user): headers = Headers() headers.set("Authorization", basic_auth_encode("*****@*****.**", "secret123")) response = client.get("/user", headers=headers) assert response.status_code == 200 assert response.json.get("user") == test_user.id
def test_401_with_invalid_credentials(client): headers = Headers() headers.set('Authorization', basic_auth_encode('invalid-username', 'invalid-password')) response = client.get('/secrets', headers=headers) assert response.status_code == 401 assert response.json.get('error') == 'invalid_token'
def test_401_with_invalid_credentials(client): headers = Headers() headers.set("Authorization", basic_auth_encode("invalid-username", "invalid-password")) response = client.get("/secrets", headers=headers) assert response.status_code == 401 assert response.json.get("error") == "invalid_token"
def test_401_with_invalid_credentials(client): headers = Headers() headers.set( "Authorization", basic_auth_encode("invalid-username", "invalid-password") ) response = client.get("/secrets", headers=headers) assert response.status_code == 401 assert response.json.get("error") == "invalid_token"
def basic_auth(email, password): headers = Headers() headers.add("Authorization", basic_auth_encode(email, password)) return headers