Ejemplo n.º 1
0
def test_apps_get_owner(preferences, logged_in_api_client, factories):
    app = factories["users.Application"](user=logged_in_api_client.user)
    url = reverse("api:v1:oauth:apps-detail",
                  kwargs={"client_id": app.client_id})
    response = logged_in_api_client.get(url)

    assert response.status_code == 200
    assert response.data == serializers.CreateApplicationSerializer(app).data
Ejemplo n.º 2
0
def test_apps_refresh_token(preferences, logged_in_api_client, factories):
    app = factories["users.Application"](user=logged_in_api_client.user)
    old_token = app.token
    url = reverse("api:v1:oauth:apps-refresh_token",
                  kwargs={"client_id": app.client_id})
    response = logged_in_api_client.post(url)

    app.refresh_from_db()
    assert response.status_code == 200
    assert response.data == serializers.CreateApplicationSerializer(app).data
    assert app.token != old_token
Ejemplo n.º 3
0
def test_apps_post(api_client, db):
    url = reverse("api:v1:oauth:apps-list")
    data = {
        "name": "Test app",
        "redirect_uris": "http://test.app",
        "scopes": "read write:profile",
    }
    response = api_client.post(url, data)

    assert response.status_code == 201

    app = models.Application.objects.get(name=data["name"])

    assert app.client_type == models.Application.CLIENT_CONFIDENTIAL
    assert app.authorization_grant_type == models.Application.GRANT_AUTHORIZATION_CODE
    assert app.redirect_uris == data["redirect_uris"]
    assert response.data == serializers.CreateApplicationSerializer(app).data
    assert app.scope == "read write:profile"
    assert app.user is None