use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class DatabaseControllerTest method startBackup.
@Test
public void startBackup() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
String xml = null;
DataSourceDumpReport report = new DataSourceDumpReport(xml);
when(databaseManager.getBackupReport(ArgumentMatchers.anyString())).thenReturn(report);
ResultActions result = mockMvc.perform(post("/database/startBackup").content("{}").header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
Mockito.verify(databaseService, Mockito.times(1)).startDatabaseBackup();
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class DatabaseControllerTest method deleteReport.
@Test
public void deleteReport() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
String xml = null;
DataSourceDumpReport report = new DataSourceDumpReport(xml);
when(databaseManager.getBackupReport(ArgumentMatchers.anyString())).thenReturn(report);
ResultActions result = mockMvc.perform(delete("/database/report/{reportCode}", new Object[] { "reportCode" }).header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
Mockito.verify(databaseService, Mockito.times(1)).deleteDumpReport("reportCode");
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class DataTypeControllerIntegrationTest method testGetDataTypes.
@Test
public void testGetDataTypes() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ResultActions result = mockMvc.perform(get("/dataTypes").header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
System.out.println(result.andReturn().getResponse().getContentAsString());
result.andExpect(header().string("Access-Control-Allow-Origin", "*"));
result.andExpect(header().string("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"));
result.andExpect(header().string("Access-Control-Allow-Headers", "Content-Type, Authorization"));
result.andExpect(header().string("Access-Control-Max-Age", "3600"));
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class DataTypeControllerTest method testUpdateNoPayload.
@Test
public void testUpdateNoPayload() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ResultActions result = mockMvc.perform(post("/dataTypes").content("{}").contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isBadRequest());
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class DataObjectModelControllerTest method should_validate_put_path_mismatch.
@Test
public void should_validate_put_path_mismatch() throws ApsSystemException, Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ObjectMapper mapper = new ObjectMapper();
DataObjectModelRequest group = new DataObjectModelRequest();
group.setModelId("2l");
group.setDescr("Description");
group.setType("AAA");
group.setModel("<p>Test</p>");
String payload = mapper.writeValueAsString(group);
this.controller.setDataObjectModelValidator(new DataObjectModelValidator());
ResultActions result = mockMvc.perform(put("/dataModels/{dataModelId}", "67").content(payload).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isBadRequest());
}
Aggregations