Repository: brooklyn-dist Updated Branches: refs/heads/master f2c711263 -> f4e69033a
http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/08f1462f/dist-karaf/itest/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTest.java ---------------------------------------------------------------------- diff --git a/dist-karaf/itest/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTest.java b/dist-karaf/itest/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTest.java new file mode 100644 index 0000000..f182f98 --- /dev/null +++ b/dist-karaf/itest/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTest.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.brooklyn.rest; + +import static org.apache.brooklyn.KarafTestUtils.defaultOptionsWith; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features; + +import java.util.concurrent.Callable; + +import org.apache.brooklyn.KarafTestUtils; +import org.apache.brooklyn.entity.brooklynnode.BrooklynNode; +import org.apache.brooklyn.test.Asserts; +import org.apache.brooklyn.util.http.HttpAsserts; +import org.apache.brooklyn.util.http.HttpTool; +import org.apache.http.HttpStatus; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerClass; + +@RunWith(PaxExam.class) +@ExamReactorStrategy(PerClass.class) +@Ignore // TODO: re-enable after brooklyn is properly initialized within the OSGI environment +public class BrooklynRestApiLauncherTest { + + private static final String HTTP_PORT = "9998"; + private static final String ROOT_URL = "http://localhost:" + HTTP_PORT; + + @Configuration + public static Option[] configuration() throws Exception { + return defaultOptionsWith( + editConfigurationFilePut("etc/org.ops4j.pax.web.cfg", "org.osgi.service.http.port", HTTP_PORT), + features(KarafTestUtils.brooklynFeaturesRepository(), "brooklyn-software-base") + // Uncomment this for remote debugging the tests on port 5005 + // ,KarafDistributionOption.debugConfiguration() + ); + } + + @Test + public void testStart() throws Exception { + ensureBrooklynStarted(); + + final String testUrl = ROOT_URL + "/v1/catalog/entities"; + int code = Asserts.succeedsEventually(new Callable<Integer>() { + @Override + public Integer call() throws Exception { + int code = HttpTool.getHttpStatusCode(testUrl); + if (code == HttpStatus.SC_FORBIDDEN) { + throw new RuntimeException("Retry request"); + } else { + return code; + } + } + }); + HttpAsserts.assertHealthyStatusCode(code); + HttpAsserts.assertContentContainsText(testUrl, BrooklynNode.class.getSimpleName()); + } + + private void ensureBrooklynStarted() { + final String upUrl = ROOT_URL + "/v1/server/up"; + HttpAsserts.assertContentEventuallyMatches(upUrl, "true"); + } +} http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/08f1462f/dist-karaf/itest/src/test/java/org/apache/brooklyn/security/CustomSecurityProvider.java ---------------------------------------------------------------------- diff --git a/dist-karaf/itest/src/test/java/org/apache/brooklyn/security/CustomSecurityProvider.java b/dist-karaf/itest/src/test/java/org/apache/brooklyn/security/CustomSecurityProvider.java new file mode 100644 index 0000000..ca9ac0e --- /dev/null +++ b/dist-karaf/itest/src/test/java/org/apache/brooklyn/security/CustomSecurityProvider.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.brooklyn.security; + +import javax.servlet.http.HttpSession; + +import org.apache.brooklyn.rest.security.provider.AbstractSecurityProvider; +import org.apache.brooklyn.rest.security.provider.SecurityProvider; + +public class CustomSecurityProvider extends AbstractSecurityProvider implements SecurityProvider { + + @Override + public boolean authenticate(HttpSession session, String user, String password) { + return "custom".equals(user); + } + +} http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/08f1462f/dist-karaf/itest/src/test/java/org/apache/brooklyn/security/CustomSecurityProviderTest.java ---------------------------------------------------------------------- diff --git a/dist-karaf/itest/src/test/java/org/apache/brooklyn/security/CustomSecurityProviderTest.java b/dist-karaf/itest/src/test/java/org/apache/brooklyn/security/CustomSecurityProviderTest.java new file mode 100644 index 0000000..3856c80 --- /dev/null +++ b/dist-karaf/itest/src/test/java/org/apache/brooklyn/security/CustomSecurityProviderTest.java @@ -0,0 +1,156 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.brooklyn.security; + +import static org.apache.brooklyn.KarafTestUtils.defaultOptionsWith; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertEquals; +import static org.ops4j.pax.exam.CoreOptions.streamBundle; + +import java.io.IOException; + +import javax.inject.Inject; +import javax.security.auth.Subject; +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.NameCallback; +import javax.security.auth.callback.PasswordCallback; +import javax.security.auth.callback.UnsupportedCallbackException; +import javax.security.auth.login.AppConfigurationEntry; +import javax.security.auth.login.FailedLoginException; +import javax.security.auth.login.LoginContext; +import javax.security.auth.login.LoginException; + +import org.apache.brooklyn.api.mgmt.ManagementContext; +import org.apache.brooklyn.core.internal.BrooklynProperties; +import org.apache.brooklyn.rest.BrooklynWebConfig; +import org.apache.brooklyn.rest.security.jaas.BrooklynLoginModule; +import org.apache.brooklyn.test.Asserts; +import org.apache.brooklyn.test.IntegrationTest; +import org.apache.karaf.features.BootFinished; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerClass; +import org.ops4j.pax.exam.util.Filter; +import org.ops4j.pax.tinybundles.core.TinyBundles; +import org.osgi.framework.Constants; + +import com.google.common.collect.ImmutableSet; + +@RunWith(PaxExam.class) +@ExamReactorStrategy(PerClass.class) +@Category(IntegrationTest.class) +public class CustomSecurityProviderTest { + private static final String WEBCONSOLE_REALM = "webconsole"; + + /** + * To make sure the tests run only when the boot features are fully + * installed + */ + @Inject + @Filter(timeout = 120000) + BootFinished bootFinished; + + @Inject + @Filter(timeout = 120000) + ManagementContext managementContext; + + @Configuration + public static Option[] configuration() throws Exception { + return defaultOptionsWith( + streamBundle(TinyBundles.bundle() + .add(CustomSecurityProvider.class) + .add("OSGI-INF/blueprint/security.xml", CustomSecurityProviderTest.class.getResource("/custom-security-bp.xml")) + .set(Constants.BUNDLE_MANIFESTVERSION, "2") // defaults to 1 which doesn't work + .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.brooklyn.test.security") + .set(Constants.BUNDLE_VERSION, "1.0.0") + .set(Constants.DYNAMICIMPORT_PACKAGE, "*") + .set(Constants.EXPORT_PACKAGE, CustomSecurityProvider.class.getPackage().getName()) + .build()) + // Uncomment this for remote debugging the tests on port 5005 + // ,KarafDistributionOption.debugConfiguration() + ); + } + + @Before + public void setUp() { + // Works only before initializing the security provider (i.e. before first use) + // TODO Dirty hack to inject the needed properties. Improve once managementContext is configurable. + // Alternatively re-register a test managementContext service (how?) + BrooklynProperties brooklynProperties = (BrooklynProperties)managementContext.getConfig(); + brooklynProperties.put(BrooklynWebConfig.SECURITY_PROVIDER_CLASSNAME.getName(), CustomSecurityProvider.class.getCanonicalName()); + } + + @Test(expected = FailedLoginException.class) + public void checkLoginFails() throws LoginException { + assertRealmRegisteredEventually(WEBCONSOLE_REALM); + doLogin("invalid", "auth"); + } + + @Test + public void checkLoginSucceeds() throws LoginException { + assertRealmRegisteredEventually(WEBCONSOLE_REALM); + String user = "custom"; + LoginContext lc = doLogin(user, "password"); + Subject subject = lc.getSubject(); + assertNotNull(subject); + assertEquals(subject.getPrincipals(), ImmutableSet.of( + new BrooklynLoginModule.UserPrincipal(user), + new BrooklynLoginModule.RolePrincipal("users"))); + } + + private LoginContext doLogin(final String username, final String password) throws LoginException { + assertRealmRegisteredEventually(WEBCONSOLE_REALM); + LoginContext lc = new LoginContext(WEBCONSOLE_REALM, new CallbackHandler() { + public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + Callback callback = callbacks[i]; + if (callback instanceof PasswordCallback) { + PasswordCallback passwordCallback = (PasswordCallback)callback; + passwordCallback.setPassword(password.toCharArray()); + } else if (callback instanceof NameCallback) { + NameCallback nameCallback = (NameCallback)callback; + nameCallback.setName(username); + } + } + } + }); + lc.login(); + return lc; + } + + private void assertRealmRegisteredEventually(final String userPassRealm) { + // Need to wait a bit for the realm to get registered, any OSGi way to do this? + Asserts.succeedsEventually(new Runnable() { + @Override + public void run() { + javax.security.auth.login.Configuration initialConfig = javax.security.auth.login.Configuration.getConfiguration(); + AppConfigurationEntry[] realm = initialConfig.getAppConfigurationEntry(userPassRealm); + assertNotNull(realm); + } + }); + } + +} http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/08f1462f/dist-karaf/itest/src/test/java/org/apache/brooklyn/security/StockSecurityProviderTest.java ---------------------------------------------------------------------- diff --git a/dist-karaf/itest/src/test/java/org/apache/brooklyn/security/StockSecurityProviderTest.java b/dist-karaf/itest/src/test/java/org/apache/brooklyn/security/StockSecurityProviderTest.java new file mode 100644 index 0000000..8ef5ceb --- /dev/null +++ b/dist-karaf/itest/src/test/java/org/apache/brooklyn/security/StockSecurityProviderTest.java @@ -0,0 +1,191 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.brooklyn.security; + +import static org.apache.brooklyn.KarafTestUtils.defaultOptionsWith; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.IOException; +import java.util.concurrent.Callable; + +import javax.inject.Inject; +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.NameCallback; +import javax.security.auth.callback.PasswordCallback; +import javax.security.auth.callback.UnsupportedCallbackException; +import javax.security.auth.login.AppConfigurationEntry; +import javax.security.auth.login.FailedLoginException; +import javax.security.auth.login.LoginContext; +import javax.security.auth.login.LoginException; + +import org.apache.brooklyn.api.mgmt.ManagementContext; +import org.apache.brooklyn.core.internal.BrooklynProperties; +import org.apache.brooklyn.rest.BrooklynWebConfig; +import org.apache.brooklyn.rest.security.provider.ExplicitUsersSecurityProvider; +import org.apache.brooklyn.test.Asserts; +import org.apache.brooklyn.test.IntegrationTest; +import org.apache.http.HttpStatus; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.CredentialsProvider; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.BasicCredentialsProvider; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.karaf.features.BootFinished; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerClass; +import org.ops4j.pax.exam.util.Filter; + +@RunWith(PaxExam.class) +@ExamReactorStrategy(PerClass.class) +@Category(IntegrationTest.class) +public class StockSecurityProviderTest { + + private static final String WEBCONSOLE_REALM = "webconsole"; + private static final String USER = "admin"; + private static final String PASSWORD = "password"; + + /** + * To make sure the tests run only when the boot features are fully + * installed + */ + @Inject + @Filter(timeout = 120000) + BootFinished bootFinished; + + @Inject + @Filter(timeout = 120000) + ManagementContext managementContext; + + @Configuration + public static Option[] configuration() throws Exception { + return defaultOptionsWith( + // Uncomment this for remote debugging the tests on port 5005 + // KarafDistributionOption.debugConfiguration() + ); + } + + @Before + public void setUp() { + //Works only before initializing the security provider (i.e. before first use) + addUser(USER, PASSWORD); + } + + @Test(expected = FailedLoginException.class) + public void checkLoginFails() throws LoginException { + doLogin("invalid", "auth"); + } + + @Test + public void checkLoginSucceeds() throws LoginException { + LoginContext lc = doLogin(USER, PASSWORD); + assertNotNull(lc.getSubject()); + } + + @Test + public void checkRestSecurityFails() throws IOException { + checkRestSecurity(null, null, HttpStatus.SC_UNAUTHORIZED); + } + + @Test + public void checkRestSecuritySucceeds() throws IOException { + checkRestSecurity(USER, PASSWORD, HttpStatus.SC_OK); + } + + private void checkRestSecurity(String username, String password, final int code) throws IOException { + CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); + if (username != null && password != null) { + credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password)); + } + try(CloseableHttpClient client = + HttpClientBuilder.create().setDefaultCredentialsProvider(credentialsProvider).build()) { + Asserts.succeedsEventually(new Callable<Void>() { + @Override + public Void call() throws Exception { + assertResponseEquals(client, code); + return null; + } + }); + } + } + + private void assertResponseEquals(CloseableHttpClient httpclient, int code) throws IOException, ClientProtocolException { + // TODO get this dynamically (from CXF service?) + // TODO port is static, should make it dynamic + HttpGet httpGet = new HttpGet("http://localhost:8081/v1/server/ha/state"); + try (CloseableHttpResponse response = httpclient.execute(httpGet)) { + assertEquals(code, response.getStatusLine().getStatusCode()); + } + } + + + private void addUser(String username, String password) { + // TODO Dirty hack to inject the needed properties. Improve once managementContext is configurable. + // Alternatively re-register a test managementContext service (how?) + BrooklynProperties brooklynProperties = (BrooklynProperties)managementContext.getConfig(); + brooklynProperties.put(BrooklynWebConfig.SECURITY_PROVIDER_CLASSNAME.getName(), ExplicitUsersSecurityProvider.class.getCanonicalName()); + brooklynProperties.put(BrooklynWebConfig.USERS.getName(), username); + brooklynProperties.put(BrooklynWebConfig.PASSWORD_FOR_USER(username), password); + } + + private LoginContext doLogin(final String username, final String password) throws LoginException { + assertRealmRegisteredEventually(WEBCONSOLE_REALM); + LoginContext lc = new LoginContext(WEBCONSOLE_REALM, new CallbackHandler() { + public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + Callback callback = callbacks[i]; + if (callback instanceof PasswordCallback) { + PasswordCallback passwordCallback = (PasswordCallback)callback; + passwordCallback.setPassword(password.toCharArray()); + } else if (callback instanceof NameCallback) { + NameCallback nameCallback = (NameCallback)callback; + nameCallback.setName(username); + } + } + } + }); + lc.login(); + return lc; + } + + private void assertRealmRegisteredEventually(final String userPassRealm) { + // Need to wait a bit for the realm to get registered, any OSGi way to do this? + Asserts.succeedsEventually(new Runnable() { + @Override + public void run() { + javax.security.auth.login.Configuration initialConfig = javax.security.auth.login.Configuration.getConfiguration(); + AppConfigurationEntry[] realm = initialConfig.getAppConfigurationEntry(userPassRealm); + assertNotNull(realm); + } + }); + } + +} http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/08f1462f/dist-karaf/itest/src/test/java/org/apache/brooklyn/test/IntegrationTest.java ---------------------------------------------------------------------- diff --git a/dist-karaf/itest/src/test/java/org/apache/brooklyn/test/IntegrationTest.java b/dist-karaf/itest/src/test/java/org/apache/brooklyn/test/IntegrationTest.java new file mode 100644 index 0000000..9f5fb43 --- /dev/null +++ b/dist-karaf/itest/src/test/java/org/apache/brooklyn/test/IntegrationTest.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.brooklyn.test; + +/** + * Used by junit for grouping tests + */ +public class IntegrationTest { + +} http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/08f1462f/dist-karaf/itest/src/test/resources/custom-security-bp.xml ---------------------------------------------------------------------- diff --git a/dist-karaf/itest/src/test/resources/custom-security-bp.xml b/dist-karaf/itest/src/test/resources/custom-security-bp.xml new file mode 100644 index 0000000..ace4454 --- /dev/null +++ b/dist-karaf/itest/src/test/resources/custom-security-bp.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Copyright 2015 The Apache Software Foundation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0" + xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws" + xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs" + xmlns:cxf="http://cxf.apache.org/blueprint/core" + xmlns:jaas="http://karaf.apache.org/xmlns/jaas/v1.0.0" + xsi:schemaLocation=" + http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd + http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org/schemas/blueprint/jaxws.xsd + http://cxf.apache.org/blueprint/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd + http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd + http://karaf.apache.org/xmlns/jaas/v1.0.0 http://karaf.apache.org/xmlns/jaas/v1.0.0 + "> + + <jaas:config name="webconsole" rank="1"> + <jaas:module className="org.apache.brooklyn.rest.security.jaas.BrooklynLoginModule" + flags="required"> + brooklyn.webconsole.security.provider.symbolicName=org.apache.brooklyn.test.security + brooklyn.webconsole.security.provider.version=1.0.0 + brooklyn.webconsole.security.provider.role=users + </jaas:module> + </jaas:config> +</blueprint> http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/08f1462f/dist-karaf/itest/src/test/resources/exam.properties ---------------------------------------------------------------------- diff --git a/dist-karaf/itest/src/test/resources/exam.properties b/dist-karaf/itest/src/test/resources/exam.properties new file mode 100644 index 0000000..d516df6 --- /dev/null +++ b/dist-karaf/itest/src/test/resources/exam.properties @@ -0,0 +1,21 @@ +################################################################################ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +pax.exam.logging = none +pax.exam.service.timeout = 5000 http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/08f1462f/dist-karaf/itest/src/test/resources/logback.xml ---------------------------------------------------------------------- diff --git a/dist-karaf/itest/src/test/resources/logback.xml b/dist-karaf/itest/src/test/resources/logback.xml new file mode 100644 index 0000000..7c08bb7 --- /dev/null +++ b/dist-karaf/itest/src/test/resources/logback.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<configuration> + + <!-- log to System.out on console --> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> + </encoder> + </appender> + + <!-- log to file test.log --> + <appender name="TEST_LOG" class="ch.qos.logback.core.FileAppender"> + <file>test.log</file> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> + </encoder> + </appender> + + <root level="INFO"> + <appender-ref ref="STDOUT" /> + <appender-ref ref="TEST_LOG" /> + </root> + <logger name="org.ops4j.pax.exam" level="INFO" /> + +</configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/08f1462f/dist-karaf/pom.xml ---------------------------------------------------------------------- diff --git a/dist-karaf/pom.xml b/dist-karaf/pom.xml new file mode 100644 index 0000000..c96fe2a --- /dev/null +++ b/dist-karaf/pom.xml @@ -0,0 +1,185 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <packaging>pom</packaging> + + <artifactId>brooklyn-dist-karaf</artifactId> + + <name>Brooklyn Karaf Distribution</name> + <description> + Brooklyn Apache Karaf distribution archive + </description> + + <parent> + <groupId>org.apache.brooklyn</groupId> + <!-- if this depends (via inheritance from brooklyn-dist) on brooklyn-server/parent, the usual parent point, + then karaf-itest has failures --> + <artifactId>brooklyn-server</artifactId> + <version>0.10.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION --> + <relativePath>../../brooklyn-server/pom.xml</relativePath> + </parent> + + <properties> + <!-- TODO: duplicates in brooklyn-server/karaf/pom.xml --> + <karaf.version>4.0.4</karaf.version> + <logback.version>1.0.7</logback.version> + <org.osgi.core.version>6.0.0</org.osgi.core.version> + <geronimo-jta_1.1_spec.version>1.1.1</geronimo-jta_1.1_spec.version> + + <org.osgi.compendium.version>5.0.0</org.osgi.compendium.version> + <lifecycle-mapping-plugin.version>1.0.0</lifecycle-mapping-plugin.version> + + <!-- pax-exam --> + <pax.exam.version>4.7.0</pax.exam.version> + <pax.url.version>2.4.3</pax.url.version> + <ops4j.base.version>1.5.0</ops4j.base.version> + <tinybundles.version>1.0.0</tinybundles.version> + + <!-- feature repositories --> + <servicemix.version>6.0.0</servicemix.version> + <reflections.bundle.version>0.9.9_1</reflections.bundle.version> <!-- see reflections.version --> + + <maven.compiler.source>${java.version}</maven.compiler.source> + <maven.compiler.target>${java.version}</maven.compiler.target> + </properties> + + <modules> + <module>apache-brooklyn</module> + <module>itest</module> + </modules> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.ops4j.base</groupId> + <artifactId>ops4j-base-lang</artifactId> + <version>${ops4j.base.version}</version> + </dependency> + <dependency> + <groupId>org.ops4j.base</groupId> + <artifactId>ops4j-base-util-property</artifactId> + <version>${ops4j.base.version}</version> + </dependency> + </dependencies> + </dependencyManagement> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>${lifecycle-mapping-plugin.version}</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-enforcer-plugin</artifactId> + <versionRange>[0,)</versionRange> + <goals> + <goal>enforce</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore/> + </action> + </pluginExecution> + <pluginExecution> + <pluginExecutionFilter> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <versionRange>[0,)</versionRange> + <goals> + <goal>attach-artifact</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore/> + </action> + </pluginExecution> + <pluginExecution> + <pluginExecutionFilter> + <groupId>org.apache.karaf.tooling</groupId> + <artifactId>karaf-maven-plugin</artifactId> + <versionRange>[0,)</versionRange> + <goals> + <goal>assembly</goal> + <goal>commands-generate-help</goal> + <goal>features-generate-descriptor</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore/> + </action> + </pluginExecution> + <pluginExecution> + <pluginExecutionFilter> + <groupId>org.apache.servicemix.tooling</groupId> + <artifactId>depends-maven-plugin</artifactId> + <versionRange>[0,)</versionRange> + <goals> + <goal>generate-depends-file</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore/> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.rat</groupId> + <artifactId>apache-rat-plugin</artifactId> + <configuration> + <excludes combine.children="append"> + <!-- Exclude sandbox because not part of distribution: not in tgz, and not uploaded to maven-central --> + <exclude>sandbox/**</exclude> + <!-- Exclude release because not part of distribution: not in tgz, and not uploaded to maven-central --> + <exclude>release/**</exclude> + <exclude>README.md</exclude> + <!-- Exclude netbeans config files (not part of the project, but often on users' drives --> + <exclude>**/nbactions.xml</exclude> + <exclude>**/nb-configuration.xml</exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + + <repositories> + <repository> + <id>servicemix</id> + <name>Apache ServiceMix Repository</name> + <url>http://svn.apache.org/repos/asf/servicemix/m2-repo</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> +</project> http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/08f1462f/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 74b5564..01073f3 100644 --- a/pom.xml +++ b/pom.xml @@ -119,6 +119,7 @@ <module>downstream-parent</module> <module>all</module> <module>dist</module> + <module>dist-karaf</module> <module>vagrant</module> <module>archetypes/quickstart</module> <module>shared-packaging</module>