package com.uwetrottmann.trakt.v2;

import org.apache.oltu.oauth2.client.response.OAuthAccessTokenResponse;
import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
import org.junit.Test;

public class AuthTest extends BaseTestCase {

    public static final String TEST_CLIENT_ID = "e683ed71dd4a4afe73ba73151a4645f511b8703464a7807045088c733ef8d634";
    public static final String TEST_CLIENT_SECRET = "21da158feb52479c53936a48b13e4abe94b907908387d47b70710deb2f4a51fa";
    private static final String AUTH_CODE = "";

    @Test
    public void test_getAccessToken() throws OAuthProblemException, OAuthSystemException {
        if (AUTH_CODE.length() == 0) {
            throw new IllegalArgumentException(
                    "Make sure you set a temporary auth code to exchange for an access token");
        }
        OAuthAccessTokenResponse response = TraktV2.getAccessToken(
                TEST_CLIENT_ID, TEST_CLIENT_SECRET, "http://localhost", AUTH_CODE);
        System.out.println("Retrieved access token: " + response.getAccessToken());
    }

}

@@ -29,16 +29,81 @@
 kt.v2;%0A%0A
+import org.apache.oltu.oauth2.client.request.OAuthClientRequest;%0A
 import o
@@ -329,16 +329,115 @@
 .Test;%0A%0A
+import java.net.URISyntaxException;%0A%0Aimport static org.fest.assertions.api.Assertions.assertThat;%0A%0A
 public c
@@ -757,16 +757,550 @@
 DE = %22%22;
+%0A    public static final String TEST_REDIRECT_URI = %22urn:ietf:wg:oauth:2.0:oob%22;%0A%0A    @Test%0A    public void test_getAccessTokenRequest() throws OAuthSystemException %7B%0A        OAuthClientRequest request = TraktV2.getAccessTokenRequest(TEST_CLIENT_ID, TEST_CLIENT_SECRET,%0A                TEST_REDIRECT_URI, AUTH_CODE);%0A        assertThat(request).isNotNull();%0A        assertThat(request.getLocationUri()).startsWith(TraktV2.OAUTH2_TOKEN_URL);%0A        System.out.println(%22Generated Token Request URI: %22 + request.getLocationUri());%0A    %7D
 %0A%0A    @T
@@ -1711,26 +1711,25 @@
 ET, 
-%22http://localhost%22
+TEST_REDIRECT_URI
 , AU
@@ -1829,10 +1829,606 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void test_getAuthorizationRequest() throws OAuthSystemException, URISyntaxException %7B%0A        OAuthClientRequest request = TraktV2.getAuthorizationRequest(TEST_CLIENT_ID, TEST_REDIRECT_URI);%0A        assertThat(request).isNotNull();%0A        assertThat(request.getLocationUri()).startsWith(TraktV2.OAUTH2_AUTHORIZATION_URL);%0A        // trakt does not support scopes, so don't send one (server sets default scope)%0A        assertThat(request.getLocationUri()).doesNotContain(%22scope%22);%0A        System.out.println(%22Generated Auth Request URI: %22 + request.getLocationUri());%0A    %7D%0A%0A
 %7D%0A

Add basic OAuth helper tests (ensure path + no scope).