use of org.jboss.shrinkwrap.descriptor.api.webapp31.WebAppDescriptor in project wildfly-swarm by wildfly-swarm.
the class HttpSecurityPreparerTest method set_2_methods.
@Test
public void set_2_methods() throws Exception {
Map<String, Object> deploymentConfig = createConfigStub();
Map<String, Object> webConfig = findWebConfig(deploymentConfig);
Map<String, Object> securityConstraint = new HashMap<>();
securityConstraint.put("methods", Arrays.asList("GET", "POST"));
webConfig.put("security-constraints", Collections.singletonList(securityConstraint));
preparer.deploymentConfigs = deploymentConfig;
preparer.process();
WebAppDescriptor webXml = Descriptors.importAs(WebAppDescriptor.class).fromStream(archive.get(WebXmlAsset.NAME).getAsset().openStream());
assertThat(webXml.getAllSecurityConstraint().size()).isEqualTo(1);
assertThat(webXml.getAllSecurityConstraint().get(0).getAllWebResourceCollection().get(0).getAllHttpMethod().get(0)).isEqualTo("GET");
assertThat(webXml.getAllSecurityConstraint().get(0).getAllWebResourceCollection().get(0).getAllHttpMethod().get(1)).isEqualTo("POST");
}
use of org.jboss.shrinkwrap.descriptor.api.webapp31.WebAppDescriptor in project wildfly-swarm by wildfly-swarm.
the class HttpSecurityPreparerTest method yaml_parsing.
@SuppressWarnings("unchecked")
@Test
public void yaml_parsing() throws Exception {
InputStream in = getClass().getClassLoader().getResourceAsStream("security.yml");
assertThat(in).isNotNull().as("security.yml is null");
Yaml yaml = new Yaml();
Map<String, Object> httpConfig = (Map<String, Object>) yaml.load(in);
preparer.deploymentConfigs = (Map) ((Map) httpConfig.get("swarm")).get("deployment");
preparer.process();
WebAppDescriptor webXml = Descriptors.importAs(WebAppDescriptor.class).fromStream(archive.get(WebXmlAsset.NAME).getAsset().openStream());
assertThat(webXml.getAllSecurityConstraint().size()).isEqualTo(1);
assertThat(webXml.getAllSecurityConstraint().get(0).getAllWebResourceCollection().get(0).getAllUrlPattern().get(0)).isEqualTo("/protected");
}
use of org.jboss.shrinkwrap.descriptor.api.webapp31.WebAppDescriptor in project wildfly-swarm by wildfly-swarm.
the class HttpSecurityPreparerTest method set_1_method.
@Test
public void set_1_method() throws Exception {
Map<String, Object> deploymentConfig = createConfigStub();
Map<String, Object> webConfig = findWebConfig(deploymentConfig);
Map<String, Object> securityConstraint = new HashMap<>();
securityConstraint.put("methods", Arrays.asList("GET"));
webConfig.put("security-constraints", Collections.singletonList(securityConstraint));
preparer.deploymentConfigs = deploymentConfig;
preparer.process();
WebAppDescriptor webXml = Descriptors.importAs(WebAppDescriptor.class).fromStream(archive.get(WebXmlAsset.NAME).getAsset().openStream());
assertThat(webXml.getAllSecurityConstraint().size()).isEqualTo(1);
assertThat(webXml.getAllSecurityConstraint().get(0).getAllWebResourceCollection().get(0).getAllHttpMethod().get(0)).isEqualTo("GET");
}
use of org.jboss.shrinkwrap.descriptor.api.webapp31.WebAppDescriptor in project tomee by apache.
the class ConnectorWithApplicationResourcesInWarTest method createDeployment.
@Deployment(testable = false)
public static WebArchive createDeployment() {
final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class);
webAppDescriptor.version("3.0");
final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war");
webArchive.addPackage("org.superbiz.connector.api");
webArchive.addPackage("org.superbiz.connector.adapter");
webArchive.addPackage("org.superbiz.application");
webArchive.addAsWebInfResource(ConnectorWithApplicationResourcesInEarTest.class.getResource("/connector/resources.xml"), "resources.xml");
webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString()));
System.out.println("Webapp:\n" + webArchive.toString(true));
return webArchive;
}
use of org.jboss.shrinkwrap.descriptor.api.webapp31.WebAppDescriptor in project tomee by apache.
the class ServletCdiInjectionTest method createDeployment.
@Deployment(testable = false)
public static WebArchive createDeployment() {
WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class).version(WebAppVersionType._3_0).createServlet().servletName("servlet").servletClass(SimpleServlet.class.getName()).up().createServletMapping().servletName("servlet").urlPattern("/" + TEST_NAME).up();
WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war").addClass(TestRun.class).addClass(SimpleServlet.class).addClass(Car.class).setWebXML(new StringAsset(descriptor.exportAsString())).addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
return archive;
}
Aggregations