Re: pax exam tests started failing when I bumped karaf version to 4.3.2

2021-05-24 Thread Steinar Bang
Thanks, Eric!

I'll study your config builders.

However, what I ended up doing in this case, was very simple: I
created a dummy users.properties file, and dropped it into the
src/test/resources/etc/ directory of the maven project for the pax exam
test:
 
https://github.com/steinarb/authservice/commit/18d4b0cb86fdb185cb0040d22ff663af7914ea1e

This was enough to stop the test from failing.



Re: pax exam tests started failing when I bumped karaf version to 4.3.2

2021-05-23 Thread Eric Lilja
Hi Steinar, for my Pax Exam Karaf tests, I am using a builder-style class I
wrote called KarafConfigurator for building the list of configuration
options.

It has methods for replacing bundled config files with user
supplied versions. Here's an example using startup.properties:

public KarafConfigurator replaceStartupProperties(final URL
newStartupProperties) throws URISyntaxException {
return replaceConfigurationFile(STARTUP_PROPERTIES_FILE_PATH,
newStartupProperties);
}

public KarafConfigurator replaceConfigurationFile(final String path, final
URL newConfigurationFileUrl) throws URISyntaxException {
final File newConfigurationFile = new
File(newConfigurationFileUrl.toURI());

return replaceConfigurationFile(path, newConfigurationFile);
}

public KarafConfigurator replaceConfigurationFile(final String path, final
File newConfigurationFile) {
final Option optionReplaceConfFile =
KarafDistributionOption.replaceConfigurationFile(path,
newConfigurationFile);

options.add(optionReplaceConfFile);

return this;
}

STARTUP_PROPERTIES_FILE_PATH denotes the path inside the Karaf distro to
the startup.properties-file. It's defined as:

private static final String STARTUP_PROPERTIES_FILE_PATH =
"etc/startup.properties";

Notice it's doesn't start with "/"

The user of KarafConfigurator-class would simply call the
replaceStartupProperties()-method. A URL to a replacement-file in
src/test/resources can be obtained simply:

final Class clz = getClass();
final URL resourceUrl = clz.getResource("/startup.properties");

Here it's assumed the file is the user wants to use as a replacement is
called "startup.properties" and is located in src/test/resources (assuming
Maven)

- Eric L

On Sun, May 23, 2021 at 11:42 AM Steinar Bang  wrote:

> > Steinar Bang :
>
> >> A simple workaround is to include your own users.properties in the
> pax-exam option.
>
> > Thanks! I will look into this.
>
> I tried this:
> @Configuration
> public Option[] config() {
> final MavenArtifactUrlReference authserviceFeatureRepo = maven()
> .groupId("no.priv.bang.authservice")
> .artifactId("karaf")
> .version("LATEST")
> .type("xml")
> .classifier("features");
> File dummyUsersProperties = new
> File(getClass().getClassLoader().getResource("dummy.users.properties").getFile());
> Option[] options = new Option[] {
> features(authserviceFeatureRepo),
> replaceConfigurationFile("/etc/users.properties",
> dummyUsersProperties)
> };
> return Stream.of(super.config(),
> options).flatMap(Stream::of).toArray(Option[]::new);
> }
>
> But the test still fails almost immediately with
>  org.ops4j.pax.exam.TestContainerException: java.lang.RuntimeException:
> Config resource /etc/users.properties not found
>
> I've tried "users.properties" and "etc/users.properties" as the
> configurationFilePath argument to replaceConfigurationFile(), but it
> didn't make any difference.
>
>


Re: pax exam tests started failing when I bumped karaf version to 4.3.2

2021-05-23 Thread Steinar Bang
> Steinar Bang :

>> A simple workaround is to include your own users.properties in the pax-exam 
>> option.

> Thanks! I will look into this.

I tried this:
@Configuration
public Option[] config() {
final MavenArtifactUrlReference authserviceFeatureRepo = maven()
.groupId("no.priv.bang.authservice")
.artifactId("karaf")
.version("LATEST")
.type("xml")
.classifier("features");
File dummyUsersProperties = new 
File(getClass().getClassLoader().getResource("dummy.users.properties").getFile());
Option[] options = new Option[] {
features(authserviceFeatureRepo),
replaceConfigurationFile("/etc/users.properties", 
dummyUsersProperties)
};
return Stream.of(super.config(), 
options).flatMap(Stream::of).toArray(Option[]::new);
}

But the test still fails almost immediately with
 org.ops4j.pax.exam.TestContainerException: java.lang.RuntimeException: Config 
resource /etc/users.properties not found

I've tried "users.properties" and "etc/users.properties" as the
configurationFilePath argument to replaceConfigurationFile(), but it
didn't make any difference.



Re: pax exam tests started failing when I bumped karaf version to 4.3.2

2021-05-23 Thread Steinar Bang
> Jean-Baptiste Onofre :

> Hi,
> It’s has been discussed on the mailing list already (I don’t remember who 
> reported this).

> The change we did is that etc/users.properties has the karaf user commented 
> now (for security reason).

Right. I noticed yesterday, when rolling the .deb package for karaf 4.3.2. :-)
 
https://steinar.bang.priv.no/2018/01/23/installing-apache-karaf-on-debian/#comment-15646

I don't know if I have any users for the .deb, besides myself, but just
in case, I guess I should make a note about the ssh change...?

A side note on this: the .deb locks down the /etc/karaf directory
because of the username/password thing (no public read access and owned
by user karaf, group karaf)

> However, etc/users.properties is still part of the karaf distribution. But, 
> as it contains only comments now, I suspect pax-exam-karaf to not include it 
> in the core distribution run. Karaf itests use it, so, it should be minor.

Yes, I suspected it was releated to the commenting out in some way.

> A simple workaround is to include your own users.properties in the pax-exam 
> option.

Thanks! I will look into this.

> I will check and create Jira for 4.3.3.

Thanks!

One note on the ssh thing: is there a Jira on being able to use ssh keys
instead of username/password in the karaf ssh?

If not, should I make one?



Re: pax exam tests started failing when I bumped karaf version to 4.3.2

2021-05-22 Thread Jean-Baptiste Onofre
Hi,

It’s has been discussed on the mailing list already (I don’t remember who 
reported this).

The change we did is that etc/users.properties has the karaf user commented now 
(for security reason).

However, etc/users.properties is still part of the karaf distribution. But, as 
it contains only comments now, I suspect pax-exam-karaf to not include it in 
the core distribution run. Karaf itests use it, so, it should be minor.

A simple workaround is to include your own users.properties in the pax-exam 
option.

I will check and create Jira for 4.3.3.

Regards
JB

> Le 23 mai 2021 à 00:27, Steinar Bang  a écrit :
> 
> When I bumped the karaf version (affects the karaf-maven-plugin, the
> karaf BoM and the pax exam tests in my project builds), then the pax
> exam tests fail with this message:
> 
> [ERROR] 
> initializationError(no.priv.bang.authservice.tests.AuthserviceIntegrationTest)
>   Time elapsed: 0.015 s  <<< ERROR!
> org.ops4j.pax.exam.TestContainerException: java.lang.RuntimeException: Config 
> resource /etc/users.properties not found
>   at 
> no.priv.bang.authservice.tests.AuthserviceIntegrationTest.config(AuthserviceIntegrationTest.java:33)
> 
> Is this expected? Do I need to make a change in my test setup?
> 
> Here's the test that failed when I bumped karaf from 4.3.0 to 4.3.2:
> https://github.com/steinarb/authservice/tree/master/authservice.tests
> 



pax exam tests started failing when I bumped karaf version to 4.3.2

2021-05-22 Thread Steinar Bang
When I bumped the karaf version (affects the karaf-maven-plugin, the
karaf BoM and the pax exam tests in my project builds), then the pax
exam tests fail with this message:

[ERROR] 
initializationError(no.priv.bang.authservice.tests.AuthserviceIntegrationTest)  
Time elapsed: 0.015 s  <<< ERROR!
org.ops4j.pax.exam.TestContainerException: java.lang.RuntimeException: Config 
resource /etc/users.properties not found
at 
no.priv.bang.authservice.tests.AuthserviceIntegrationTest.config(AuthserviceIntegrationTest.java:33)

Is this expected? Do I need to make a change in my test setup?

Here's the test that failed when I bumped karaf from 4.3.0 to 4.3.2:
 https://github.com/steinarb/authservice/tree/master/authservice.tests