Search in sources :

Example 1 with UserDataService

use of org.alfresco.rest.api.tests.client.UserDataService in project alfresco-remote-api by Alfresco.

the class EnterpriseWorkflowTestApi method before.

@Before
public void before() throws Exception {
    this.applicationContext = getTestFixture().getApplicationContext();
    this.repoService = getTestFixture().getRepoService();
    this.transactionHelper = (RetryingTransactionHelper) applicationContext.getBean("retryingTransactionHelper");
    this.personService = (PersonService) applicationContext.getBean("PersonService");
    this.nodeService = (NodeService) applicationContext.getBean("NodeService");
    this.serviceRegistry = (ServiceRegistry) applicationContext.getBean("ServiceRegistry");
    HttpClientProvider httpClientProvider = (HttpClientProvider) applicationContext.getBean("httpClientProvider");
    UserDataService userDataService = new UserDataService() {

        @Override
        public UserData findUserByUserName(String userName) {
            UserData userData = new UserData();
            if (userName.startsWith("admin")) {
                userData.setUserName(userName);
                userData.setPassword("admin");
                userData.setId(userName);
            } else {
                TestPerson person = getRepoService().getPerson(userName.toLowerCase());
                userData.setUserName(person.getId());
                userData.setPassword(person.getPassword());
                userData.setId(person.getId());
            }
            return userData;
        }
    };
    AuthenticationDetailsProvider authenticationDetailsProvider = new UserAuthenticationDetailsProviderImpl(userDataService, "admin", "admin");
    AuthenticatedHttp authenticatedHttp = new AuthenticatedHttp(httpClientProvider, authenticationDetailsProvider);
    this.httpClient = new WorkflowApiHttpClient("localhost", TestFixture.PORT, TestFixture.CONTEXT_PATH, TestFixture.PUBLIC_API_SERVLET_NAME, authenticatedHttp);
    this.publicApiClient = new WorkflowApiClient(httpClient, userDataService);
    activitiProcessEngine = (ProcessEngine) applicationContext.getBean("activitiProcessEngine");
}
Also used : AuthenticationDetailsProvider(org.alfresco.rest.api.tests.client.AuthenticationDetailsProvider) HttpClientProvider(org.alfresco.rest.api.tests.client.HttpClientProvider) UserData(org.alfresco.rest.api.tests.client.UserData) AuthenticatedHttp(org.alfresco.rest.api.tests.client.AuthenticatedHttp) UserAuthenticationDetailsProviderImpl(org.alfresco.rest.api.tests.client.UserAuthenticationDetailsProviderImpl) TestPerson(org.alfresco.rest.api.tests.RepoService.TestPerson) UserDataService(org.alfresco.rest.api.tests.client.UserDataService) Before(org.junit.Before)

Example 2 with UserDataService

use of org.alfresco.rest.api.tests.client.UserDataService in project alfresco-remote-api by Alfresco.

the class AbstractTestApi method setupTests.

@Before
public void setupTests() throws Exception {
    TestFixture testFixture = getTestFixture(false);
    this.applicationContext = testFixture.getApplicationContext();
    this.repoService = testFixture.getRepoService();
    this.transactionHelper = (RetryingTransactionHelper) applicationContext.getBean("retryingTransactionHelper");
    HttpClientProvider httpClientProvider = (HttpClientProvider) applicationContext.getBean("httpClientProvider");
    UserDataService userDataService = new UserDataService() {

        @Override
        public UserData findUserByUserName(String userName) {
            UserData userData = new UserData();
            TestPerson person = getRepoService().getPerson(userName.toLowerCase());
            userData.setUserName(person.getId());
            userData.setPassword(person.getPassword());
            userData.setId(person.getId());
            return userData;
        }
    };
    AuthenticationDetailsProvider authenticationDetailsProvider = new UserAuthenticationDetailsProviderImpl(userDataService, "admin", "admin");
    AuthenticatedHttp authenticatedHttp = new AuthenticatedHttp(httpClientProvider, authenticationDetailsProvider);
    this.httpClient = new PublicApiHttpClient(TestFixture.HOST, TestFixture.PORT, TestFixture.CONTEXT_PATH, TestFixture.PUBLIC_API_SERVLET_NAME, authenticatedHttp);
    this.publicApiClient = new PublicApiClient(httpClient, userDataService);
}
Also used : AuthenticationDetailsProvider(org.alfresco.rest.api.tests.client.AuthenticationDetailsProvider) HttpClientProvider(org.alfresco.rest.api.tests.client.HttpClientProvider) UserData(org.alfresco.rest.api.tests.client.UserData) AuthenticatedHttp(org.alfresco.rest.api.tests.client.AuthenticatedHttp) PublicApiHttpClient(org.alfresco.rest.api.tests.client.PublicApiHttpClient) PublicApiClient(org.alfresco.rest.api.tests.client.PublicApiClient) UserAuthenticationDetailsProviderImpl(org.alfresco.rest.api.tests.client.UserAuthenticationDetailsProviderImpl) TestPerson(org.alfresco.rest.api.tests.RepoService.TestPerson) UserDataService(org.alfresco.rest.api.tests.client.UserDataService) Before(org.junit.Before)

Aggregations

TestPerson (org.alfresco.rest.api.tests.RepoService.TestPerson)2 AuthenticatedHttp (org.alfresco.rest.api.tests.client.AuthenticatedHttp)2 AuthenticationDetailsProvider (org.alfresco.rest.api.tests.client.AuthenticationDetailsProvider)2 HttpClientProvider (org.alfresco.rest.api.tests.client.HttpClientProvider)2 UserAuthenticationDetailsProviderImpl (org.alfresco.rest.api.tests.client.UserAuthenticationDetailsProviderImpl)2 UserData (org.alfresco.rest.api.tests.client.UserData)2 UserDataService (org.alfresco.rest.api.tests.client.UserDataService)2 Before (org.junit.Before)2 PublicApiClient (org.alfresco.rest.api.tests.client.PublicApiClient)1 PublicApiHttpClient (org.alfresco.rest.api.tests.client.PublicApiHttpClient)1