Author: [email protected]
Date: Fri May 13 14:56:37 2011
New Revision: 1137

Log:
[AMDATUAUTH-23] Moved all auth integration tests to Amdatu Auth

Added:
   
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthServiceConsumerRegistryTest.java
   
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthThreeLeggedTest.java
   
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthTwoLeggedTest.java
   
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/util/AuthUtils.java
Modified:
   
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceProviderImpl.java
   
trunk/amdatu-auth/test-integration/base/src/main/java/org/amdatu/auth/test/integration/base/AuthFixture.java
   trunk/amdatu-auth/test-integration/pom.xml
   trunk/amdatu-auth/test-integration/tests/pom.xml
   
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/AuthTest.java
   
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthSignedRequestsTest.java
   
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/util/OAuthTestBase.java

Modified: 
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceProviderImpl.java
==============================================================================
--- 
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceProviderImpl.java
   (original)
+++ 
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceProviderImpl.java
   Fri May 13 14:56:37 2011
@@ -15,19 +15,19 @@
  */
 package org.amdatu.authentication.oauth.server.service;
 
-import static 
org.amdatu.authentication.oauth.server.OAuthServerConfig.AUTHORIZE_URL;
-import static 
org.amdatu.authentication.oauth.server.OAuthServerConfig.HOSTNAME;
-import static org.amdatu.authentication.oauth.server.OAuthServerConfig.PORTNR;
-
-import java.util.Dictionary;
-
-import org.amdatu.authentication.oauth.api.OAuthServiceProvider;
-import org.amdatu.authentication.oauth.server.OAuthAccessTokenServlet;
-import org.amdatu.authentication.oauth.server.OAuthAuthorizeTokenServlet;
-import org.amdatu.authentication.oauth.server.OAuthRequestTokenServlet;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
-import org.osgi.service.log.LogService;
+import static 
org.amdatu.authentication.oauth.server.OAuthServerConfig.AUTHORIZE_URL;
+import static 
org.amdatu.authentication.oauth.server.OAuthServerConfig.HOSTNAME;
+import static org.amdatu.authentication.oauth.server.OAuthServerConfig.PORTNR;
+
+import java.util.Dictionary;
+
+import org.amdatu.authentication.oauth.api.OAuthServiceProvider;
+import org.amdatu.authentication.oauth.server.OAuthAccessTokenServlet;
+import org.amdatu.authentication.oauth.server.OAuthAuthorizeTokenServlet;
+import org.amdatu.authentication.oauth.server.OAuthRequestTokenServlet;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.log.LogService;
 
 public class OAuthServiceProviderImpl implements OAuthServiceProvider, 
ManagedService {
     private volatile LogService m_logService;
@@ -77,10 +77,14 @@
     }
 
     public void start() {
-        m_logService.log(LogService.LOG_DEBUG, "oAuth serviec provider started 
with config: hostname=" + m_hostName
+        m_logService.log(LogService.LOG_DEBUG, "oAuth service provider started 
with config: hostname=" + m_hostName
             + ", portnr=" + m_portNr + ", authorizeurl=" + m_authorizeUrl);
     }
-
+
+    public void stop() {
+        m_logService.log(LogService.LOG_DEBUG, "oAuth service provider 
stopped");
+    }
+    
     @SuppressWarnings("unchecked")
     public void updated(final Dictionary dictionary) throws 
ConfigurationException {
         if (dictionary != null) {

Modified: 
trunk/amdatu-auth/test-integration/base/src/main/java/org/amdatu/auth/test/integration/base/AuthFixture.java
==============================================================================
--- 
trunk/amdatu-auth/test-integration/base/src/main/java/org/amdatu/auth/test/integration/base/AuthFixture.java
        (original)
+++ 
trunk/amdatu-auth/test-integration/base/src/main/java/org/amdatu/auth/test/integration/base/AuthFixture.java
        Fri May 13 14:56:37 2011
@@ -16,6 +16,7 @@
 package org.amdatu.auth.test.integration.base;
 
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
 
 import java.util.Properties;
 
@@ -29,6 +30,17 @@
     
     public Option provision() {
         return org.ops4j.pax.exam.CoreOptions.provision(
+            // Wrap libraries we depend on as OSGi bundles and provision those
+            
wrappedBundle(mavenBundle().groupId("commons-httpclient").artifactId("commons-httpclient").versionAsInProject()),
+            
wrappedBundle(mavenBundle().groupId("commons-codec").artifactId("commons-codec").versionAsInProject()),
+            
wrappedBundle(mavenBundle().groupId("commons-logging").artifactId("commons-logging").versionAsInProject()),
+            
wrappedBundle(mavenBundle().groupId("org.json").artifactId("json").versionAsInProject()),
+            
+            // The following 2 artifacts are necessary for default tenant 
resolving
+            
mavenBundle().groupId("org.amdatu.web").artifactId("org.amdatu.web.tenantresolver.hostname").versionAsInProject(),
+            
mavenBundle().groupId("org.amdatu.web").artifactId("org.amdatu.web.tenantresolver.parameter").versionAsInProject(),
+            
+            // Provision Amdatu Auth bundles
             
mavenBundle().groupId("org.amdatu.auth").artifactId("org.amdatu.auth.test.integration.base").versionAsInProject(),
             
mavenBundle().groupId("org.amdatu.auth").artifactId("org.amdatu.auth.tokenprovider").versionAsInProject(),
             
mavenBundle().groupId("org.amdatu.auth").artifactId("org.amdatu.auth.tokenstore.mem").versionAsInProject(),
@@ -36,11 +48,7 @@
             
mavenBundle().groupId("org.amdatu.auth").artifactId("org.amdatu.auth.oauth.client").versionAsInProject(),
             
mavenBundle().groupId("org.amdatu.auth").artifactId("org.amdatu.auth.oauth.server").versionAsInProject(),
             
mavenBundle().groupId("org.amdatu.auth").artifactId("org.amdatu.auth.oauth.consumerregistry-fs").versionAsInProject(),
-            
mavenBundle().groupId("org.amdatu.auth").artifactId("org.amdatu.auth.login.service").versionAsInProject(),
-            
-            // The following 2 artifacts are necessary for default tenant 
resolving
-            
mavenBundle().groupId("org.amdatu.web").artifactId("org.amdatu.web.tenantresolver.hostname").versionAsInProject(),
-            
mavenBundle().groupId("org.amdatu.web").artifactId("org.amdatu.web.tenantresolver.parameter").versionAsInProject()
+            
mavenBundle().groupId("org.amdatu.auth").artifactId("org.amdatu.auth.login.service").versionAsInProject()
             );
     }
     

Modified: trunk/amdatu-auth/test-integration/pom.xml
==============================================================================
--- trunk/amdatu-auth/test-integration/pom.xml  (original)
+++ trunk/amdatu-auth/test-integration/pom.xml  Fri May 13 14:56:37 2011
@@ -133,7 +133,6 @@
       <artifactId>org.amdatu.web.itest.base</artifactId>
       <type>bundle</type>
     </dependency>
-
   </dependencies>
 
 </project>
\ No newline at end of file

Modified: trunk/amdatu-auth/test-integration/tests/pom.xml
==============================================================================
--- trunk/amdatu-auth/test-integration/tests/pom.xml    (original)
+++ trunk/amdatu-auth/test-integration/tests/pom.xml    Fri May 13 14:56:37 2011
@@ -35,6 +35,37 @@
 
   <dependencyManagement>
     <dependencies>
+      <!--
+        External library dependencies used by the integration tests.
+      -->
+      <dependency>
+        <groupId>commons-codec</groupId>
+        <artifactId>commons-codec</artifactId>
+        <version>1.4</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>commons-httpclient</groupId>
+        <artifactId>commons-httpclient</artifactId>
+        <version>3.1</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>commons-logging</groupId>
+        <artifactId>commons-logging</artifactId>
+        <version>1.1.1</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.json</groupId>
+        <artifactId>json</artifactId>
+        <version>20090211</version>
+        <scope>test</scope>
+      </dependency>
+
+      <!--
+        Amdatu Web itest base to be used by the tests.
+      -->
       <dependency>
         <groupId>org.amdatu.web</groupId>
         <artifactId>org.amdatu.web.tenantresolver.hostname</artifactId>
@@ -117,6 +148,22 @@
       See explanation in the dependencyManagement section above.
     -->
     <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-httpclient</groupId>
+      <artifactId>commons-httpclient</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.json</groupId>
+      <artifactId>json</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.amdatu.web</groupId>
       <artifactId>org.amdatu.web.tenantresolver.hostname</artifactId>
       <type>bundle</type>

Modified: 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/AuthTest.java
==============================================================================
--- 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/AuthTest.java
 (original)
+++ 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/AuthTest.java
 Fri May 13 14:56:37 2011
@@ -22,15 +22,14 @@
 import static org.ops4j.pax.exam.LibraryOptions.junitBundles;
 
 import java.io.IOException;
-import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
-import java.net.URL;
 import java.util.Dictionary;
 import java.util.Hashtable;
 
 import javax.servlet.Servlet;
 
 import org.amdatu.auth.test.integration.base.AuthFixture;
+import org.amdatu.auth.test.integration.tests.util.AuthUtils;
 import org.amdatu.auth.test.integration.tests.util.OAuthProtectedTestServlet;
 import org.amdatu.auth.test.integration.tests.util.OAuthTestBase;
 import org.amdatu.authentication.oauth.api.OAuthServiceConsumerRegistry;
@@ -41,6 +40,7 @@
 import org.amdatu.authentication.oauth.server.OAuthTokenProvider;
 import org.amdatu.core.itest.base.CoreFixture;
 import org.amdatu.core.itest.base.TestContext;
+import org.amdatu.core.tenant.TenantManagementService;
 import org.amdatu.web.itest.base.WebFixture;
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
@@ -56,13 +56,13 @@
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.http.HttpService;
 import org.osgi.service.log.LogService;
+import org.osgi.service.useradmin.UserAdmin;
 
 @RunWith(JUnit4TestRunner.class)
 @ExamReactorStrategy(AllConfinedStagedReactorFactory.class)
-public class AuthTest {
-
-    // Time out for the http service to come available
-    private final static int HTTP_TIMEOUT = 10000;
+public class AuthTest {    
+    public final static String TEST_USERNAME = "georged";
+    public final static String TEST_PASSWORD = "georged";
     
     // Fixtures used by the Auth integration tests
     private CoreFixture m_coreFixture = new CoreFixture();
@@ -73,6 +73,8 @@
     private LogService m_logService;
     private OAuthServiceProvider m_oAuthServiceProvider;
     private OAuthServiceConsumerRegistry m_consumerRegistry;
+    private UserAdmin m_userAdmin;
+    private TenantManagementService m_tenantService;
     
     @Configuration
     public Option[] config() {
@@ -86,7 +88,7 @@
     public TestContext testContextSetUp(BundleContext bundleContext) throws 
Exception {
         assertThat(bundleContext, is(notNullValue()));
         TestContext testContext = new TestContext(bundleContext);
-
+        
         // FIXME quickfix to let startlevel complete to
         // prevent felix bundle locking issues
         Thread.sleep(1000);
@@ -148,8 +150,10 @@
         assertAvailable(testContext, OAuthAccessTokenServlet.class);
         m_consumerRegistry = assertAvailable(testContext, 
OAuthServiceConsumerRegistry.class);
         assertAvailable(testContext, HttpService.class);
+        m_userAdmin =  assertAvailable(testContext, UserAdmin.class);
         m_oAuthServiceProvider = assertAvailable(testContext, 
OAuthServiceProvider.class);
-        
+        m_tenantService = assertAvailable(testContext, 
TenantManagementService.class);
+            
         // Register an oAuth protected test servlet we need during the tests
         registerTestResource();
         
@@ -157,9 +161,10 @@
         waitForOAuthServlets();
         
         // Execute the tests
-        OAuthSignedRequestsTest test = new OAuthSignedRequestsTest();
-        init(test);
-        test.execute();
+        test(OAuthServiceConsumerRegistryTest.class);
+        test(OAuthSignedRequestsTest.class);
+        test(OAuthThreeLeggedTest.class);
+        test(OAuthTwoLeggedTest.class);
         
         // And we are done
         testContext.tearDown();
@@ -179,69 +184,31 @@
         m_dependencyManager.add(servletComponent);
     }
     
+    private <T extends OAuthTestBase> void test(Class<T> testClass) throws 
Exception {
+        T test = testClass.newInstance();
+        init(test);
+        test.execute();
+    }
+    
     private void init(OAuthTestBase test) {
         test.setLogService(m_logService);
+        test.setUserAdmin(m_userAdmin);
         test.setOAuthServiceProvider(m_oAuthServiceProvider);
         test.setOAuthServiceConsumerRegistry(m_consumerRegistry);
+        test.setTenantService(m_tenantService);
     }
     
     protected void waitForOAuthServlets() throws MalformedURLException, 
IOException {
         // First wait for the request servlet to become available
         m_logService.log(LogService.LOG_DEBUG, "Waiting for '" + 
m_oAuthServiceProvider.getRequestTokenURL()
             + "' to come available...");
-        waitForURL(m_oAuthServiceProvider.getRequestTokenURL(), 
HttpStatus.SC_UNAUTHORIZED);
+        AuthUtils.waitForURL(m_oAuthServiceProvider.getRequestTokenURL(), 
HttpStatus.SC_UNAUTHORIZED);
         m_logService.log(LogService.LOG_DEBUG, "Waiting for '" + 
m_oAuthServiceProvider.getAuthorizeTokenURL()
             + "' to come available...");
-        waitForURL(m_oAuthServiceProvider.getAuthorizeTokenURL(), 
HttpStatus.SC_UNAUTHORIZED);
+        AuthUtils.waitForURL(m_oAuthServiceProvider.getAuthorizeTokenURL(), 
HttpStatus.SC_UNAUTHORIZED);
         m_logService.log(LogService.LOG_DEBUG, "Waiting for '" + 
m_oAuthServiceProvider.getAccessTokenURL()
             + "' to come available...");
-        waitForURL(m_oAuthServiceProvider.getAccessTokenURL(), 
HttpStatus.SC_UNAUTHORIZED);
+        AuthUtils.waitForURL(m_oAuthServiceProvider.getAccessTokenURL(), 
HttpStatus.SC_UNAUTHORIZED);
         m_logService.log(LogService.LOG_DEBUG, "oAuth servlets available");
     }
-
-    protected void waitForURL(String url, int status) throws 
MalformedURLException, IOException {
-        if (!waitForURL(new URL(url), status, HTTP_TIMEOUT)) {
-            int responseCode = checkURL(new URL(url));
-            throw new IllegalArgumentException("Timeout occurred waiting for 
'" + url
-                + "' to come available, response code=" + responseCode);
-        }
-    }
-    
-
-    /**
-     * Wait until the service at the specified URL returns the specified 
response code with a timeout as specified.
-     * 
-     * @throws IOException
-     */
-    public static boolean waitForURL(URL url, int responseCode, int timeout) 
throws IOException {
-        long deadline = System.currentTimeMillis() + timeout;
-        while (System.currentTimeMillis() < deadline) {
-            try {
-                if (checkURL(url) == responseCode) {
-                    return true;
-                }
-                Thread.sleep(100);
-            }
-            catch (InterruptedException ie) {}
-            catch (IOException e) {}
-        }
-        return false;
-    }
-    
-    /**
-     * Invokes a URL and returns the response code.
-     * 
-     * @throws IOException
-     */
-    public static int checkURL(URL url) throws IOException {
-        HttpURLConnection connection = (HttpURLConnection) 
url.openConnection();
-        int responseCode;
-        try {
-            connection.connect();
-            responseCode = connection.getResponseCode();
-        } finally {
-            connection.disconnect();
-        }
-        return responseCode;
-    }
 }

Added: 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthServiceConsumerRegistryTest.java
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthServiceConsumerRegistryTest.java
 Fri May 13 14:56:37 2011
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2010, 2011 The Amdatu Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.amdatu.auth.test.integration.tests;
+
+import java.io.IOException;
+
+import org.amdatu.auth.test.integration.base.AuthFixture;
+import org.amdatu.auth.test.integration.tests.util.OAuthTestBase;
+import org.amdatu.auth.test.integration.tests.util.OAuthTestConsumer;
+import org.amdatu.auth.test.integration.tests.util.AuthUtils;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.http.HttpStatus;
+import org.json.JSONException;
+import org.junit.Assert;
+import org.osgi.service.log.LogService;
+
+public class OAuthServiceConsumerRegistryTest extends OAuthTestBase {
+    private final static String CONSUMERS_REST_RESOURCE = 
"/rest/oauth/consumers";
+
+    private String m_baseUrl;
+
+    // Test the REST service that provides CRUD operations on the consumer 
registry of the oAuth server
+    public void execute() throws Exception {
+        m_baseUrl = "http://"; + AuthFixture.HOSTNAME + ":" + 
AuthFixture.PORTNR;
+        m_logService.log(LogService.LOG_DEBUG, "Base URL = " + m_baseUrl);
+
+        // Wait for the REST service to become available
+        m_logService.log(LogService.LOG_DEBUG, "Waiting for '" + m_baseUrl + 
CONSUMERS_REST_RESOURCE + "' to come available...");
+        AuthUtils.waitForURL(m_baseUrl + CONSUMERS_REST_RESOURCE, 
HttpStatus.SC_OK);
+        m_logService.log(LogService.LOG_DEBUG, "URL available");
+
+        HttpClient httpClient = new HttpClient();
+
+        // First add a new consumer using the JSON format
+        OAuthTestConsumer consumer = new OAuthTestConsumer();
+        int statusCode = putConsumer(httpClient, "application/json", consumer, 
false);
+        Assert.assertTrue("OAuth Service Consumer registry REST service 
returns " + statusCode + " on addConsumer",
+            statusCode == HttpStatus.SC_OK);
+
+        // Retrieve the new consumer in XML and JSON format
+        OAuthTestConsumer testConsumer = getConsumer(httpClient, 
"application/json", consumer.getConsumerKey());
+        Assert.assertTrue("Returned JSON consumer is incorrect: " + 
testConsumer.toString(),
+            consumer.equals(testConsumer));
+        testConsumer = getConsumer(httpClient, "application/xml", 
consumer.getConsumerKey());
+        Assert.assertTrue("Returned XML consumer is incorrect",
+            consumer.equals(testConsumer));
+
+        // Now try to add another consumer using the Atom XML format, this 
should result in a 304 since the consumer
+        // already exists
+        statusCode = putConsumer(httpClient, "application/json", consumer, 
false);
+        Assert.assertTrue("OAuth Service Consumer registry REST service 
returns " + statusCode + " on addConsumer",
+            statusCode == HttpStatus.SC_NOT_MODIFIED);
+
+        // Now update the test consumer
+        consumer.setConsumerSecret("new " + 
OAuthTestConsumer.DEFAULT_CONSUMER_SECRET);
+        consumer.setCallbackUrl("new " + 
OAuthTestConsumer.DEFAULT_CALLBACK_URL);
+        consumer.setName("new " + OAuthTestConsumer.DEFAULT_CONSUMER_NAME);
+        statusCode = putConsumer(httpClient, "application/json", consumer, 
true);
+        Assert.assertTrue("OAuth Service Consumer registry REST service 
returns " + statusCode + " on updateConsumer",
+            statusCode == HttpStatus.SC_OK);
+
+        // And check if the update was handled properly
+        testConsumer = getConsumer(httpClient, "application/json", 
consumer.getConsumerKey());
+        Assert.assertTrue("Returned JSON consumer is incorrect: " + 
testConsumer.toString(),
+            consumer.equals(testConsumer));
+        testConsumer = getConsumer(httpClient, "application/xml", 
consumer.getConsumerKey());
+        Assert.assertTrue("Returned XML consumer is incorrect",
+            consumer.equals(testConsumer));
+
+        // Now delete our test consumer
+        statusCode = deleteConsumer(httpClient, "application/json", 
consumer.getConsumerKey());
+        Assert.assertTrue("OAuth Service Consumer registry REST service 
returns " + statusCode + " on deleteConsumer",
+            statusCode == HttpStatus.SC_OK);
+    }
+
+    private OAuthTestConsumer getConsumer(HttpClient httpClient, String 
mimeType, String consumerKey) throws HttpException, IOException, JSONException {
+        String url = m_baseUrl + CONSUMERS_REST_RESOURCE;
+        GetMethod getMethod = new GetMethod(url + "/" + consumerKey);
+        try {
+            // We want JSON!
+            getMethod.setRequestHeader("Accept", mimeType);
+            int statusCode = httpClient.executeMethod(getMethod);
+            Assert.assertTrue("OAuth Service Consumer registry REST service 
returns " + statusCode + " on getConsumer",
+                statusCode == HttpStatus.SC_OK);
+            String body = new String(getMethod.getResponseBody(), "UTF-8");
+            m_logService.log(LogService.LOG_DEBUG, "Returned content for 
getConsumer in format " + mimeType + ": " + body);
+            if ("application/json".equals(mimeType)) {
+                return OAuthTestConsumer.fromJson(body);
+            } else if ("application/xml".equals(mimeType)) {
+                return OAuthTestConsumer.fromXML(body);
+            } else {
+                return null;
+            }
+        }
+        finally {
+            // Release the connection.
+            getMethod.releaseConnection();
+        }
+    }
+
+    private int putConsumer(HttpClient httpClient, String mimeType, 
OAuthTestConsumer consumer, boolean update) throws JSONException, 
HttpException, IOException {
+        String url = m_baseUrl + CONSUMERS_REST_RESOURCE;
+        PutMethod method;
+        if (update) {
+            method = new PutMethod(url + "/" + consumer.getConsumerKey());
+        } else {
+            method = new PutMethod(url);
+        }
+        String body = null;
+        if ("application/xml".equals(mimeType)) {
+            body = consumer.toXML();
+        } else if ("application/json".equals(mimeType)) {
+            body = consumer.toJson().toString();
+        }
+        m_logService.log(LogService.LOG_DEBUG, "Adding consumer for " + 
mimeType + ", url=" + (update ? url + "/"
+            + consumer.getConsumerKey() : url) + ", input=" + body);
+        RequestEntity requestEntity = new StringRequestEntity(body, mimeType, 
"UTF-8");
+        method.setRequestEntity(requestEntity);
+
+        // Execute the method, this should return a 200
+        try {
+            method.setRequestHeader("Content-type", mimeType);
+            return httpClient.executeMethod(method);
+        }
+        finally {
+            // Release the connection.
+            method.releaseConnection();
+        }
+    }
+
+    private int deleteConsumer(HttpClient httpClient, String mimeType, String 
consumerKey) throws JSONException, HttpException, IOException {
+        String url = m_baseUrl + CONSUMERS_REST_RESOURCE;
+        DeleteMethod method = new DeleteMethod(url + "/" + consumerKey);
+        m_logService.log(LogService.LOG_DEBUG, "Deleting consumer for " + 
mimeType + ", input=" + consumerKey);
+
+        // Execute the method, this should return a 200
+        try {
+            return httpClient.executeMethod(method);
+        }
+        finally {
+            // Release the connection.
+            method.releaseConnection();
+        }
+    }
+}

Modified: 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthSignedRequestsTest.java
==============================================================================
--- 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthSignedRequestsTest.java
  (original)
+++ 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthSignedRequestsTest.java
  Fri May 13 14:56:37 2011
@@ -49,10 +49,8 @@
         try {
             m_consumerRegistry.removeConsumer(consumer);
         }
-        catch (ConsumerNotFoundException e) {
-        }
-        catch (ConsumerRegistryStorageException e) {
-        }
+        catch (ConsumerNotFoundException e) {}
+        catch (ConsumerRegistryStorageException e) {}
         m_consumerRegistry.addConsumer(consumer);
 
         // Step 2: Create an OAuthClient for our Amdatu OAuth server

Added: 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthThreeLeggedTest.java
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthThreeLeggedTest.java
     Fri May 13 14:56:37 2011
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2010, 2011 The Amdatu Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.amdatu.auth.test.integration.tests;
+
+import static 
org.amdatu.auth.test.integration.tests.util.OAuthProtectedTestServlet.OAUTH_TYPE_PARAM;
+import static 
org.amdatu.auth.test.integration.tests.util.OAuthProtectedTestServlet.OAUTH_TYPE_THREE_LEGGED;
+import junit.framework.Assert;
+import net.oauth.OAuthAccessor;
+import net.oauth.OAuthMessage;
+
+import org.amdatu.auth.test.integration.base.AuthFixture;
+import org.amdatu.auth.test.integration.tests.util.AuthUtils;
+import org.amdatu.auth.test.integration.tests.util.OAuthProtectedTestServlet;
+import org.amdatu.auth.test.integration.tests.util.OAuthTestBase;
+import org.amdatu.auth.test.integration.tests.util.OAuthTestConsumer;
+import org.amdatu.authentication.oauth.api.ConsumerNotFoundException;
+import org.amdatu.authentication.oauth.api.ConsumerRegistryStorageException;
+import org.amdatu.authentication.oauth.api.OAuthServiceConsumer;
+import org.amdatu.authentication.oauth.client.OAuthResourceOwnerClient;
+import org.amdatu.authentication.oauth.client.OAuthServiceConsumerClient;
+import org.osgi.service.log.LogService;
+
+/**
+ * Test class for 3-legged oAuth
+ *
+ * @author ivol
+ */
+public class OAuthThreeLeggedTest extends OAuthTestBase {
+
+    public void execute() throws Exception {
+        // Step 1: Register a service consumer
+        m_logService.log(LogService.LOG_DEBUG, "*** Step 1: Register service 
consumer ***");
+        OAuthServiceConsumer consumer = new OAuthTestConsumer();
+        try {
+            m_consumerRegistry.removeConsumer(consumer);
+        }
+        catch (ConsumerNotFoundException e) {}
+        catch (ConsumerRegistryStorageException e) {}
+        m_consumerRegistry.addConsumer(consumer);
+
+        // Step 2: Create an OAuthClient for our Amdatu OAuth server
+        m_logService.log(LogService.LOG_DEBUG, "*** Step 2: Create OAuth 
Clients ***");
+        OAuthServiceConsumerClient consumerClient = new 
OAuthServiceConsumerClient(m_oAuthServiceProvider, consumer);
+        OAuthResourceOwnerClient userClient = new 
OAuthResourceOwnerClient(m_oAuthServiceProvider, consumer);
+
+        // Step 3: Generate a request token for our service consumer
+        m_logService.log(LogService.LOG_DEBUG, "*** Step 3: Generate request 
token ***");
+        OAuthAccessor accessor = createRequestToken(consumerClient);
+
+        // Step 4: Log in using an Amdatu account, just after creating it
+        m_logService.log(LogService.LOG_DEBUG, "*** Step 4: Log in with Amdatu 
account '" + AuthTest.TEST_USERNAME + "' ***");
+        AuthUtils.addTestUser(m_userAdmin);
+        login();
+
+        // Step 5: Authorize the request token for a user we define
+        m_logService.log(LogService.LOG_DEBUG, "*** Step 5: Authorize the 
request token ***");
+        String callback = userClient.authorizeToken(accessor, 
getCookieHeader());
+        
Assert.assertTrue(callback.startsWith(OAuthTestConsumer.DEFAULT_CALLBACK_URL + 
"?oauth_token="));
+        m_logService.log(LogService.LOG_DEBUG, "Callback URL received: " + 
callback);
+
+        // Step 6: Exchange our request token for an access token
+        m_logService.log(LogService.LOG_DEBUG, "*** Step 6: Get access token 
***");
+        OAuthMessage message = consumerClient.getAccessToken(accessor);
+        accessor.accessToken = message.getToken();
+        accessor.tokenSecret = message.getParameter("oauth_token_secret");
+        accessor.requestToken = null;
+        m_logService.log(LogService.LOG_DEBUG, "Access token received: " + 
accessor.accessToken + ", with secret "
+            + accessor.tokenSecret);
+
+        // Step 7: Access a protected resource
+        m_logService.log(LogService.LOG_DEBUG, "*** Step 7: Access protected 
resource ***");
+        String url = "http://"; + AuthFixture.HOSTNAME + ":" + 
AuthFixture.PORTNR + OAuthProtectedTestServlet.SERVLET_ALIAS;
+        url += "?" + OAUTH_TYPE_PARAM + "=" + OAUTH_TYPE_THREE_LEGGED;
+        message = consumerClient.accessResource(accessor, url, "GET");
+        String body = message.readBodyAsString();
+        m_logService.log(LogService.LOG_DEBUG, "Protected resource returns 
response: '" + body + "'");
+        Assert.assertTrue(body.equals("userid=" + AuthTest.TEST_USERNAME));
+
+        // Step 8: Cleanup; remove the consumer and our test user
+        m_consumerRegistry.removeConsumer(consumer);
+        AuthUtils.removeTestUser(m_userAdmin);
+    }
+
+    // Step 3: Generate a request token for our service consumer
+    private OAuthAccessor createRequestToken(OAuthServiceConsumerClient 
client) throws Exception {
+        OAuthAccessor accessor = client.generateRequestToken();
+        String requestToken = accessor.requestToken;
+        String tokenSecret = accessor.tokenSecret;
+        m_logService.log(LogService.LOG_DEBUG, "Request token received: " + 
requestToken + ", token secret="
+            + tokenSecret);
+        return accessor;
+    }
+}

Added: 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthTwoLeggedTest.java
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthTwoLeggedTest.java
       Fri May 13 14:56:37 2011
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2010, 2011 The Amdatu Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.amdatu.auth.test.integration.tests;
+
+import static org.amdatu.auth.test.integration.tests.AuthTest.TEST_USERNAME;
+import static 
org.amdatu.auth.test.integration.tests.util.OAuthProtectedTestServlet.OAUTH_TYPE_PARAM;
+import static 
org.amdatu.auth.test.integration.tests.util.OAuthProtectedTestServlet.OAUTH_TYPE_TWO_LEGGED;
+import static 
org.amdatu.auth.test.integration.tests.util.OAuthProtectedTestServlet.SERVLET_ALIAS;
+import junit.framework.Assert;
+import net.oauth.OAuthAccessor;
+import net.oauth.OAuthMessage;
+
+import org.amdatu.auth.test.integration.base.AuthFixture;
+import org.amdatu.auth.test.integration.tests.util.AuthUtils;
+import org.amdatu.auth.test.integration.tests.util.OAuthTestBase;
+import org.amdatu.auth.test.integration.tests.util.OAuthTestConsumer;
+import org.amdatu.authentication.oauth.api.OAuthServiceConsumer;
+import org.amdatu.authentication.oauth.client.OAuthResourceOwnerClient;
+import org.amdatu.authentication.oauth.client.OAuthServiceConsumerClient;
+import org.osgi.service.log.LogService;
+
+public class OAuthTwoLeggedTest extends OAuthTestBase {
+
+    public void execute() throws Exception {
+       // Since this test is not tenant aware, verify that there is only 1 
tenant
+        Assert.assertTrue(m_tenantService.getTenants().size() + " tenants 
exist, this test has not been written to cope with deal with multiple tenants",
+            m_tenantService.getTenants().size() == 1);
+
+        // Step 1: Register a service consumer
+        m_logService.log(LogService.LOG_DEBUG, "*** Step 1a: Register service 
consumer ***");
+        OAuthServiceConsumer consumer = new OAuthTestConsumer();
+        m_consumerRegistry.addConsumer(consumer);
+
+        // Step 2: validate that the user id has not yet been added to the 
consumer registry
+        Assert.assertFalse(
+            "Userid '" + TEST_USERNAME + "' already added to allowed userids 
in the service consumer registry",
+            m_consumerRegistry.hasResourceAccess(consumer, TEST_USERNAME));
+
+        // Step 3: perform a 3-legged oAuth dance for user 'ivol'
+        // Step 3a: Create an OAuthClient for our Amdatu OAuth server
+        m_logService.log(LogService.LOG_DEBUG, "*** Step 3a: Create OAuth 
Clients ***");
+        OAuthServiceConsumerClient consumerClient = new 
OAuthServiceConsumerClient(m_oAuthServiceProvider, consumer);
+        OAuthResourceOwnerClient userClient = new 
OAuthResourceOwnerClient(m_oAuthServiceProvider, consumer);
+
+        // Step 3b: Generate a request token for our service consumer
+        m_logService.log(LogService.LOG_DEBUG, "*** Step 3b: Generate request 
token ***");
+        OAuthAccessor accessor = createRequestToken(consumerClient);
+
+        // Step 3c: Log in using an Amdatu account, but create that account 
first
+        m_logService.log(LogService.LOG_DEBUG, "*** Step 3c: Log in with 
Amdatu account '" + TEST_USERNAME + "' ***");
+        AuthUtils.addTestUser(m_userAdmin);
+        login();
+
+        // Step 3d: Authorize the request token for a user we define
+        m_logService.log(LogService.LOG_DEBUG, "*** Step 3d: Authorize the 
request token ***");
+        userClient.authorizeToken(accessor, getCookieHeader());
+
+        // Step 3e: Exchange our request token for an access token
+        m_logService.log(LogService.LOG_DEBUG, "*** Step 3e: Get access token 
***");
+        OAuthMessage message = consumerClient.getAccessToken(accessor);
+        accessor.accessToken = message.getToken();
+        accessor.tokenSecret = message.getParameter("oauth_token_secret");
+        accessor.requestToken = null;
+
+        // Step 4: validate if the user id has been added to the consumer 
registry
+        Assert.assertTrue(
+            "Userid '" + TEST_USERNAME + "', not added to allowed userids in 
the service consumer registry",
+            m_consumerRegistry.hasResourceAccess(consumer, TEST_USERNAME));
+
+        // Step 5: Now access a 2-legged protected resource
+        String url = "http://"; + AuthFixture.HOSTNAME + ":" + 
AuthFixture.PORTNR + SERVLET_ALIAS;
+        url += "?" + OAUTH_TYPE_PARAM + "=" + OAUTH_TYPE_TWO_LEGGED;
+        message = consumerClient.accessResource(accessor, url, "GET");
+        String body = message.readBodyAsString();
+        m_logService.log(LogService.LOG_DEBUG, "Protected resource returns 
response: '" + body + "'");
+        Assert.assertTrue(body.equals("userid=" + TEST_USERNAME));
+
+        // Step 7: Withdraw the access, then try to access the protected 
resource again
+        m_consumerRegistry.withdrawResourceAccess(consumer, TEST_USERNAME);
+        message = consumerClient.accessResource(accessor, url, "GET");
+        body = message.readBodyAsString();
+        m_logService.log(LogService.LOG_DEBUG, "Protected resource returns 
response: '" + body + "'");
+        Assert.assertTrue(body.equals("access denied"));
+
+        // Step 8: Cleanup; remove the consumer and our test user
+        m_consumerRegistry.removeConsumer(consumer);
+        AuthUtils.removeTestUser(m_userAdmin);
+    }
+
+    // Step 1c: Generate a request token for our service consumer
+    private OAuthAccessor createRequestToken(OAuthServiceConsumerClient 
client) throws Exception {
+        OAuthAccessor accessor = client.generateRequestToken();
+        String requestToken = accessor.requestToken;
+        String tokenSecret = accessor.tokenSecret;
+        m_logService.log(LogService.LOG_DEBUG, "Request token received: " + 
requestToken + ", token secret="
+            + tokenSecret);
+        return accessor;
+    }
+}

Added: 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/util/AuthUtils.java
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/util/AuthUtils.java
   Fri May 13 14:56:37 2011
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2010, 2011 The Amdatu Foundation
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.amdatu.auth.test.integration.tests.util;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import junit.framework.Assert;
+
+import org.amdatu.auth.test.integration.base.AuthFixture;
+import org.amdatu.auth.test.integration.tests.AuthTest;
+import org.amdatu.authentication.tokenprovider.TokenProvider;
+import org.amdatu.authorization.login.service.LoginService;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HeaderElement;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.osgi.service.useradmin.Role;
+import org.osgi.service.useradmin.User;
+import org.osgi.service.useradmin.UserAdmin;
+
+public class AuthUtils {
+    // Time out for the http service to come available
+    private final static int HTTP_TIMEOUT = 10000;
+    
+    public static void waitForURL(String url, int status) throws 
MalformedURLException, IOException {
+        if (!waitForURL(new URL(url), status, HTTP_TIMEOUT)) {
+            int responseCode = checkURL(new URL(url));
+            throw new IllegalArgumentException("Timeout occurred waiting for 
'" + url
+                + "' to come available, response code=" + responseCode);
+        }
+    }
+    
+    /**
+     * Wait until the service at the specified URL returns the specified 
response code with a timeout as specified.
+     * 
+     * @throws IOException
+     */
+    public static boolean waitForURL(URL url, int responseCode, int timeout) 
throws IOException {
+        long deadline = System.currentTimeMillis() + timeout;
+        while (System.currentTimeMillis() < deadline) {
+            try {
+                if (checkURL(url) == responseCode) {
+                    return true;
+                }
+                Thread.sleep(100);
+            }
+            catch (InterruptedException ie) {}
+            catch (IOException e) {}
+        }
+        return false;
+    }
+    
+    /**
+     * Invokes a URL and returns the response code.
+     * 
+     * @throws IOException
+     */
+    public static int checkURL(URL url) throws IOException {
+        HttpURLConnection connection = (HttpURLConnection) 
url.openConnection();
+        int responseCode;
+        try {
+            connection.connect();
+            responseCode = connection.getResponseCode();
+        } finally {
+            connection.disconnect();
+        }
+        return responseCode;
+    }
+    
+    @SuppressWarnings("unchecked")
+    public static void addTestUser(UserAdmin userAdmin) {
+        User user = (User) userAdmin.createRole(AuthTest.TEST_USERNAME, 
Role.USER);
+        user.getCredentials().put(LoginService.PASSWORD_CREDENTIAL_KEY, 
AuthTest.TEST_PASSWORD);
+        Assert.assertTrue("Test user '" + AuthTest.TEST_USERNAME + "' could 
not be created", userAdmin.getRole(AuthTest.TEST_USERNAME) != null);
+    }
+
+    public static void removeTestUser(UserAdmin userAdmin) {
+        userAdmin.removeRole(AuthTest.TEST_USERNAME);
+        Assert.assertFalse("Test user '" + AuthTest.TEST_USERNAME + "' could 
not be removed", userAdmin.getRole(AuthTest.TEST_USERNAME) != null);
+    }
+    
+    public static HeaderElement login(String host, String username, String 
password) throws HttpException, IOException {
+        String loginUrl = "http://"; + host + ":" + AuthFixture.PORTNR + 
"/rest/authorization/login";
+        HttpClient httpClient = new HttpClient();
+        PostMethod postMethod = null;
+        try {
+            postMethod = new PostMethod(loginUrl);
+            postMethod.addParameter("username", username);
+            postMethod.addParameter("password", password);
+            postMethod.addRequestHeader("Content-Type", 
"application/x-www-form-urlencoded;charset=UTF-8");
+            int status = httpClient.executeMethod(postMethod);
+            Assert.assertTrue("Login failed using Amdatu account '" + username 
+ "', response code=" + status,
+                status == HttpStatus.SC_OK);
+            Header cookieHeader = postMethod.getResponseHeader("Set-Cookie");
+            if (cookieHeader != null) {
+                HeaderElement[] headerElements = cookieHeader.getElements();
+                for (HeaderElement headerElement : headerElements) {
+                    if 
(TokenProvider.TOKEN_COOKIE_NAME.equalsIgnoreCase(headerElement.getName())) {
+                        return headerElement;
+                    }
+                }
+            }
+        }
+        finally {
+            postMethod.releaseConnection();
+        }
+        return null;
+    }
+}

Modified: 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/util/OAuthTestBase.java
==============================================================================
--- 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/util/OAuthTestBase.java
       (original)
+++ 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/util/OAuthTestBase.java
       Fri May 13 14:56:37 2011
@@ -15,24 +15,34 @@
  */
 package org.amdatu.auth.test.integration.tests.util;
 
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.amdatu.auth.test.integration.base.AuthFixture;
+import org.amdatu.auth.test.integration.tests.AuthTest;
 import org.amdatu.authentication.oauth.api.OAuthServiceConsumerRegistry;
 import org.amdatu.authentication.oauth.api.OAuthServiceProvider;
+import org.amdatu.core.tenant.TenantManagementService;
+import org.apache.commons.httpclient.HeaderElement;
+import org.apache.commons.httpclient.HttpException;
 import org.osgi.service.log.LogService;
-
+import org.osgi.service.useradmin.UserAdmin;
 
 public abstract class OAuthTestBase {
     protected volatile LogService m_logService;
     protected volatile OAuthServiceProvider m_oAuthServiceProvider;
     protected volatile OAuthServiceConsumerRegistry m_consumerRegistry;
+    protected volatile UserAdmin m_userAdmin;
+    protected volatile TenantManagementService m_tenantService;
     
+    private HeaderElement m_cookieHeaderElement;
     
  /*   
     protected volatile ConfigurationAdmin m_configAdmin;
     protected volatile DependencyManager m_dependencyManager;
-    protected volatile OAuthTokenProvider m_tokenProvider;
-    
-    protected volatile UserAdmin m_userAdmin;
-    protected volatile TenantManagementService m_tenantService;*/
+    protected volatile OAuthTokenProvider m_tokenProvider;    
+*/
 
     public abstract void execute() throws Exception;
     
@@ -48,63 +58,24 @@
         m_consumerRegistry = registry;
     }
     
-    /*
-    private HeaderElement m_cookieHeaderElement;
-
-
-
-    protected void initConfiguration() throws IOException {
-        m_configAdmin = getService(ConfigurationAdmin.class);
-
-        // Add cassandra and templates configs
-        ConfigProvider configProvider = new ConfigProvider();
-        configProvider.addTenantConfig(m_configAdmin);
-        configProvider.addFSTenantStoreConfig(m_configAdmin);
-        configProvider.addFelixHttpServiceConfig(m_configAdmin);
-        configProvider.addOAuthConfig(m_configAdmin);
-        configProvider.addLogConfig(m_configAdmin);
-        configProvider.addFSConsumerStoreConfig(m_configAdmin);
-        configProvider.addFSUserAdminConfig(m_configAdmin);
-    }
-
-    protected Component[] getDependencies(DependencyManager manager) {
-        // Now register a test servlet
-        OAuthProtectedTestServlet m_testServlet = new 
OAuthProtectedTestServlet();
-        Dictionary<String, String> servletProperties = new Hashtable<String, 
String>();
-        servletProperties.put("alias", 
OAuthProtectedTestServlet.SERVLET_ALIAS);
-        Component servletComponent = manager.createComponent()
-        .setImplementation(m_testServlet)
-        .setInterface(new String[] { Servlet.class.getName() }, 
servletProperties)
-        
.add(manager.createServiceDependency().setService(LogService.class).setRequired(true))
-        
.add(manager.createServiceDependency().setService(OAuthServiceConsumerRegistry.class).setRequired(true))
-        
.add(manager.createServiceDependency().setService(OAuthTokenProvider.class).setRequired(true));
-
-        Component testComponent = manager.createComponent()
-        .setImplementation(this)
-        
.add(manager.createServiceDependency().setService(OAuthRequestTokenServlet.class).setRequired(true))
-        
.add(manager.createServiceDependency().setService(OAuthTokenProvider.class).setRequired(true))
-        
.add(manager.createServiceDependency().setService(OAuthServiceProvider.class).setRequired(true))
-        
.add(manager.createServiceDependency().setService(ConfigurationAdmin.class).setRequired(true))
-        
.add(manager.createServiceDependency().setService(OAuthServiceConsumerRegistry.class).setRequired(true))
-        
.add(manager.createServiceDependency().setService(HttpService.class).setRequired(true))
-        
.add(manager.createServiceDependency().setService(UserAdmin.class).setRequired(true))
-        
.add(manager.createServiceDependency().setService(LoginService.class).setRequired(true))
-        
.add(manager.createServiceDependency().setService(StorageProvider.class).setRequired(true))
-        
.add(manager.createServiceDependency().setService(TenantManagementService.class).setRequired(true))
-        
.add(manager.createServiceDependency().setService(LogService.class).setRequired(true));
-
-        return new Component[] { servletComponent, testComponent };
-    }
-    protected void login() throws HttpException, IOException {
-        m_cookieHeaderElement = Login.login(ConfigProvider.HOSTNAME, 
TEST_USERNAME, TEST_PASSWORD);
+    public void setUserAdmin(UserAdmin userAdmin) {
+        m_userAdmin = userAdmin;
+    }
+    
+    public void setTenantService(TenantManagementService tenantService) {
+        m_tenantService = tenantService;
+    }
+    
+    protected void login() throws HttpException, IOException {
+        m_cookieHeaderElement = AuthUtils.login(AuthFixture.HOSTNAME, 
AuthTest.TEST_USERNAME, AuthTest.TEST_PASSWORD);
+    }
+
+    protected Map<String, String> getCookieHeader() {
+        Map<String, String> requestHeaders = new HashMap<String, String>();
+        if (m_cookieHeaderElement != null) {
+            String header = m_cookieHeaderElement.getName() + "=" + 
m_cookieHeaderElement.getValue();
+            requestHeaders.put("Cookie", header);
+        }
+        return requestHeaders;
     }
-
-    protected Map<String, String> getCookieHeader() {
-        Map<String, String> requestHeaders = new HashMap<String, String>();
-        if (m_cookieHeaderElement != null) {
-            String header = m_cookieHeaderElement.getName() + "=" + 
m_cookieHeaderElement.getValue();
-            requestHeaders.put("Cookie", header);
-        }
-        return requestHeaders;
-    }*/
 }
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits

Reply via email to