@Test
public void createVenTest() throws Exception {

	// create login auth app no certificate gen
	VenCreateDto dto = new VenCreateDto();
	dto.setCommonName("myapp");
	dto.setUsername("myapp");
	dto.setAuthenticationType("login");
	dto.setPassword("pass");
	byte[] content = mapper.writeValueAsBytes(dto);
	MvcResult andReturn = this.mockMvc
			.perform(MockMvcRequestBuilders.post(VEN_URL).content(content)
					.header("Content-Type", "application/json").with(adminSession))
			.andExpect(MockMvcResultMatchers.status().is(HttpStatus.CREATED_201)).andReturn();
	assertEquals(0, andReturn.getResponse().getContentLength());
	// verify app has been created
	Ven findByUsername = venService.findOneByUsername("myapp");
	assertNotNull(findByUsername);
	venService.delete(findByUsername);
	// create x509 auth app no certificate gen
	dto = new VenCreateDto();
	dto.setCommonName("myapp");
	dto.setUsername("myapp");
	dto.setAuthenticationType("x509");
	content = mapper.writeValueAsBytes(dto);
	andReturn = this.mockMvc
			.perform(MockMvcRequestBuilders.post(VEN_URL).content(content)
					.header("Content-Type", "application/json").with(adminSession))
			.andExpect(MockMvcResultMatchers.status().is(HttpStatus.CREATED_201)).andReturn();
	assertEquals(0, andReturn.getResponse().getContentLength());
	// verify app has been created
	findByUsername = venService.findOneByUsername("myapp");
	assertNotNull(findByUsername);
	venService.delete(findByUsername);
	// create x509 app user rsa certificate gen
	dto = new VenCreateDto();
	dto.setCommonName("myapp");
	dto.setAuthenticationType("x509");
	dto.setNeedCertificateGeneration("rsa");
	content = mapper.writeValueAsBytes(dto);
	andReturn = this.mockMvc
			.perform(MockMvcRequestBuilders.post(VEN_URL).content(content)
					.header("Content-Type", "application/json").with(adminSession))
			.andExpect(MockMvcResultMatchers.status().is(HttpStatus.CREATED_201)).andReturn();
	assertNotEquals(0, andReturn.getResponse().getContentLength());
	// verify app has been created
	assertNotNull(andReturn.getResponse().getHeader("x-VenID"));
	findByUsername = venService.findOneByUsername(andReturn.getResponse().getHeader("x-VenID"));
	assertNotNull(findByUsername);
	assertFalse(findByUsername.getReportOnly());
	assertFalse(findByUsername.getXmlSignature());
	venService.delete(findByUsername);
	// create x509 auth app ecc certificate gen
	dto = new VenCreateDto();
	dto.setCommonName("myapp");
	dto.setAuthenticationType("x509");
	dto.setNeedCertificateGeneration("ecc");
	dto.setReportOnly(true);
	dto.setXmlSignature(true);
	content = mapper.writeValueAsBytes(dto);
	andReturn = this.mockMvc
			.perform(MockMvcRequestBuilders.post(VEN_URL).content(content)
					.header("Content-Type", "application/json").with(adminSession))
			.andExpect(MockMvcResultMatchers.status().is(HttpStatus.CREATED_201)).andReturn();
	assertNotEquals(0, andReturn.getResponse().getContentLength());
	// verify app has been created
	assertNotNull(andReturn.getResponse().getHeader("x-VenID"));
	findByUsername = venService.findOneByUsername(andReturn.getResponse().getHeader("x-VenID"));
	assertNotNull(findByUsername);
	assertTrue(findByUsername.getReportOnly());
	assertTrue(findByUsername.getXmlSignature());
	venService.delete(findByUsername);
}