Search in sources :

Example 26 with Authentication

use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.

the class IdentityServiceTest method testSetAuthenticatedUserId.

@Test
public void testSetAuthenticatedUserId() {
    identityService.setAuthenticatedUserId("john");
    Authentication currentAuthentication = identityService.getCurrentAuthentication();
    assertNotNull(currentAuthentication);
    assertEquals("john", currentAuthentication.getUserId());
    assertNull(currentAuthentication.getGroupIds());
    assertNull(currentAuthentication.getTenantIds());
}
Also used : Authentication(org.camunda.bpm.engine.impl.identity.Authentication) Test(org.junit.Test)

Example 27 with Authentication

use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.

the class RuntimeAuthorizationQueryPerformanceTest method params.

@Parameters(name = "{0} - {4}")
public static Iterable<Object[]> params() {
    final ArrayList<Object[]> params = new ArrayList<Object[]>();
    for (Object[] queryResourcesAndPermission : queryResourcesAndPermissions) {
        for (Authentication authentication : authentications) {
            Object[] array = new Object[queryResourcesAndPermission.length + 1];
            System.arraycopy(queryResourcesAndPermission, 0, array, 0, queryResourcesAndPermission.length);
            array[queryResourcesAndPermission.length] = authentication;
            params.add(array);
        }
    }
    return params;
}
Also used : Authentication(org.camunda.bpm.engine.impl.identity.Authentication) ArrayList(java.util.ArrayList) Parameters(org.junit.runners.Parameterized.Parameters)

Example 28 with Authentication

use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.

the class HistoryAuthorizationQueryPerformanceTest method params.

@Parameters(name = "{0} - {4}")
public static Iterable<Object[]> params() {
    final ArrayList<Object[]> params = new ArrayList<Object[]>();
    for (Object[] queryResourcesAndPermission : queryResourcesAndPermissions) {
        for (Authentication authentication : authentications) {
            Object[] array = new Object[queryResourcesAndPermission.length + 1];
            System.arraycopy(queryResourcesAndPermission, 0, array, 0, queryResourcesAndPermission.length);
            array[queryResourcesAndPermission.length] = authentication;
            params.add(array);
        }
    }
    return params;
}
Also used : Authentication(org.camunda.bpm.engine.impl.identity.Authentication) ArrayList(java.util.ArrayList) Parameters(org.junit.runners.Parameterized.Parameters)

Example 29 with Authentication

use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.

the class RepositoryAuthorizationQueryPerformanceTest method params.

@Parameters(name = "{0} - {4}")
public static Iterable<Object[]> params() {
    final ArrayList<Object[]> params = new ArrayList<Object[]>();
    for (Object[] queryResourcesAndPermission : queryResourcesAndPermissions) {
        for (Authentication authentication : authentications) {
            Object[] array = new Object[queryResourcesAndPermission.length + 1];
            System.arraycopy(queryResourcesAndPermission, 0, array, 0, queryResourcesAndPermission.length);
            array[queryResourcesAndPermission.length] = authentication;
            params.add(array);
        }
    }
    return params;
}
Also used : Authentication(org.camunda.bpm.engine.impl.identity.Authentication) ArrayList(java.util.ArrayList) Parameters(org.junit.runners.Parameterized.Parameters)

Example 30 with Authentication

use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.

the class FetchAndLockRestServiceInteractionTest method shouldSetAuthenticationProperly.

@Ignore
@Test
public void shouldSetAuthenticationProperly() {
    when(identityServiceMock.getCurrentAuthentication()).thenReturn(new Authentication(MockProvider.EXAMPLE_USER_ID, groupIds, tenantIds));
    FetchExternalTasksExtendedDto fetchExternalTasksDto = createDto(500L);
    given().contentType(ContentType.JSON).body(fetchExternalTasksDto).pathParam("name", "default").when().post(FETCH_EXTERNAL_TASK_URL_NAMED_ENGINE);
    ArgumentCaptor<Authentication> argumentCaptor = ArgumentCaptor.forClass(Authentication.class);
    verify(identityServiceMock, atLeastOnce()).setAuthentication(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue().getUserId(), is(MockProvider.EXAMPLE_USER_ID));
    assertThat(argumentCaptor.getValue().getGroupIds(), is(groupIds));
    assertThat(argumentCaptor.getValue().getTenantIds(), is(tenantIds));
}
Also used : Authentication(org.camunda.bpm.engine.impl.identity.Authentication) FetchExternalTasksExtendedDto(org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Aggregations

Authentication (org.camunda.bpm.engine.impl.identity.Authentication)56 Test (org.junit.Test)29 Matchers.anyString (org.mockito.Matchers.anyString)22 ArrayList (java.util.ArrayList)9 IdentityService (org.camunda.bpm.engine.IdentityService)9 User (org.camunda.bpm.engine.identity.User)5 AuthorizationUtil (org.camunda.bpm.engine.rest.util.AuthorizationUtil)5 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)4 Group (org.camunda.bpm.engine.identity.Group)4 GroupQuery (org.camunda.bpm.engine.identity.GroupQuery)4 UserQuery (org.camunda.bpm.engine.identity.UserQuery)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)3 Parameters (org.junit.runners.Parameterized.Parameters)3 AuthorizationService (org.camunda.bpm.engine.AuthorizationService)2 Authorization (org.camunda.bpm.engine.authorization.Authorization)2 AuthorizationQuery (org.camunda.bpm.engine.authorization.AuthorizationQuery)2 MissingAuthorization (org.camunda.bpm.engine.authorization.MissingAuthorization)2 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)2 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)2