Ejemplo n.º 1
0
        protected internal virtual Tenant createTenant(string tenantId)
        {
            Tenant newTenant = identityService.newTenant(tenantId);

            identityService.saveTenant(newTenant);
            return(newTenant);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void failToUpdateTenantForReadOnlyService()
        public virtual void failToUpdateTenantForReadOnlyService()
        {
            Tenant updatedTenant = MockProvider.createMockTenant();

            when(identityServiceMock.ReadOnly).thenReturn(true);

            given().pathParam("id", MockProvider.EXAMPLE_TENANT_ID).body(TenantDto.fromTenant(updatedTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(InvalidRequestException).Name)).body("message", equalTo("Identity service implementation is read-only.")).when().put(TENANT_URL);

            verify(identityServiceMock, never()).saveTenant(mockTenant);
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createTenantThrowsAuthorizationException()
        public virtual void createTenantThrowsAuthorizationException()
        {
            Tenant newTenant = MockProvider.createMockTenant();

            string message = "exception expected";

            when(identityServiceMock.newTenant(MockProvider.EXAMPLE_TENANT_ID)).thenThrow(new AuthorizationException(message));

            given().body(TenantDto.fromTenant(newTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(AuthorizationException).Name)).body("message", equalTo(message)).when().post(TENANT_CREATE_URL);
        }
Ejemplo n.º 4
0
        public static HalTenant fromTenant(Tenant tenant)
        {
            HalTenant halTenant = new HalTenant();

            halTenant.id   = tenant.Id;
            halTenant.name = tenant.Name;

            halTenant.linker.createLink(REL_SELF, tenant.Id);

            return(halTenant);
        }
Ejemplo n.º 5
0
        protected internal virtual TenantQuery setUpMockQuery(Tenant tenant)
        {
            TenantQuery query = mock(typeof(TenantQuery));

            when(query.tenantId(anyString())).thenReturn(query);
            when(query.singleResult()).thenReturn(tenant);

            when(identityServiceMock.createTenantQuery()).thenReturn(query);

            return(query);
        }
Ejemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createExistingTenant()
        public virtual void createExistingTenant()
        {
            Tenant newTenant = MockProvider.createMockTenant();

            when(identityServiceMock.newTenant(MockProvider.EXAMPLE_TENANT_ID)).thenReturn(newTenant);

            string message = "exception expected";

            doThrow(new ProcessEngineException(message)).when(identityServiceMock).saveTenant(newTenant);

            given().body(TenantDto.fromTenant(newTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(ProcessEngineException).Name)).body("message", equalTo(message)).when().post(TENANT_CREATE_URL);
        }
Ejemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createTenant()
        public virtual void createTenant()
        {
            Tenant newTenant = MockProvider.createMockTenant();

            when(identityServiceMock.newTenant(MockProvider.EXAMPLE_TENANT_ID)).thenReturn(newTenant);

            given().body(TenantDto.fromTenant(mockTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.NO_CONTENT.StatusCode).when().post(TENANT_CREATE_URL);

            verify(identityServiceMock).newTenant(MockProvider.EXAMPLE_TENANT_ID);
            verify(newTenant).Name = MockProvider.EXAMPLE_TENANT_NAME;
            verify(identityServiceMock).saveTenant(newTenant);
        }
Ejemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void updateTenantThrowsAuthorizationException()
        public virtual void updateTenantThrowsAuthorizationException()
        {
            Tenant updatedTenant = MockProvider.createMockTenant();

            when(updatedTenant.Name).thenReturn("updatedName");

            string message = "exception expected";

            doThrow(new AuthorizationException(message)).when(identityServiceMock).saveTenant(any(typeof(Tenant)));

            given().pathParam("id", MockProvider.EXAMPLE_TENANT_ID).body(TenantDto.fromTenant(updatedTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(AuthorizationException).Name)).body("message", equalTo(message)).when().put(TENANT_URL);
        }
Ejemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void updateNonExistingTenant()
        public virtual void updateNonExistingTenant()
        {
            Tenant updatedTenant = MockProvider.createMockTenant();

            when(updatedTenant.Name).thenReturn("updatedName");

            when(mockQuery.singleResult()).thenReturn(null);

            given().pathParam("id", "aNonExistingTenant").body(TenantDto.fromTenant(updatedTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.NOT_FOUND.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(InvalidRequestException).Name)).body("message", equalTo("Tenant with id aNonExistingTenant does not exist")).when().put(TENANT_URL);

            verify(identityServiceMock, never()).saveTenant(any(typeof(Tenant)));
        }
Ejemplo n.º 10
0
        public virtual TenantDto getTenant(UriInfo context)
        {
            Tenant tenant = findTenantObject();

            if (tenant == null)
            {
                throw new InvalidRequestException(Status.NOT_FOUND, "Tenant with id " + resourceId + " does not exist");
            }

            TenantDto dto = TenantDto.fromTenant(tenant);

            return(dto);
        }
Ejemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void updateTenant()
        public virtual void updateTenant()
        {
            Tenant updatedTenant = MockProvider.createMockTenant();

            when(updatedTenant.Name).thenReturn("updatedName");

            given().pathParam("id", MockProvider.EXAMPLE_TENANT_ID).body(TenantDto.fromTenant(updatedTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.NO_CONTENT.StatusCode).when().put(TENANT_URL);

            // tenant was updated
            verify(mockTenant).Name = updatedTenant.Name;

            // and then saved
            verify(identityServiceMock).saveTenant(mockTenant);
        }
Ejemplo n.º 12
0
        public virtual void updateTenant(TenantDto tenantDto)
        {
            ensureNotReadOnly();

            Tenant tenant = findTenantObject();

            if (tenant == null)
            {
                throw new InvalidRequestException(Status.NOT_FOUND, "Tenant with id " + resourceId + " does not exist");
            }

            tenantDto.update(tenant);

            identityService.saveTenant(tenant);
        }
Ejemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setupData()
        public virtual void setupData()
        {
            identityServiceMock            = mock(typeof(IdentityService));
            authorizationServiceMock       = mock(typeof(AuthorizationService));
            processEngineConfigurationMock = mock(typeof(ProcessEngineConfiguration));

            // mock identity service
            when(processEngine.IdentityService).thenReturn(identityServiceMock);
            // authorization service
            when(processEngine.AuthorizationService).thenReturn(authorizationServiceMock);
            // process engine configuration
            when(processEngine.ProcessEngineConfiguration).thenReturn(processEngineConfigurationMock);

            mockTenant = MockProvider.createMockTenant();
            mockQuery  = setUpMockQuery(mockTenant);
        }
Ejemplo n.º 14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogTenantDeletion()
        public virtual void shouldLogTenantDeletion()
        {
            // given
            Tenant newTenant = identityService.newTenant(TEST_TENANT_ID);

            identityService.saveTenant(newTenant);
            assertEquals(0, query.count());

            // when
            identityService.AuthenticatedUserId = "userId";
            identityService.deleteTenant(newTenant.Id);
            identityService.clearAuthentication();

            // then
            assertLog(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_DELETE, EntityTypes.TENANT, null, TEST_TENANT_ID);
        }
Ejemplo n.º 15
0
 public virtual AuthorizationEntity[] tenantMembershipCreated(Tenant tenant, Group group)
 {
     return(null);
 }
Ejemplo n.º 16
0
 public virtual AuthorizationEntity[] newTenant(Tenant tenant)
 {
     return(null);
 }