Skip to content

Commit af5863c

Browse files
Fix wrong permission setup for HiveMQ container (#8399)
Co-authored-by: Eddú Meléndez Gonzales <[email protected]>
1 parent 8bec80c commit af5863c

14 files changed

+62
-32
lines changed

modules/hivemq/build.gradle

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ dependencies {
1111
shaded("org.jboss.shrinkwrap:shrinkwrap-impl-base:1.2.6")
1212
shaded("net.lingala.zip4j:zip4j:2.11.5")
1313

14-
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
14+
testImplementation("org.junit.jupiter:junit-jupiter:5.10.1")
1515
testImplementation(project(":junit-jupiter"))
1616
testImplementation("com.hivemq:hivemq-extension-sdk:4.24.0")
1717
testImplementation("com.hivemq:hivemq-mqtt-client:1.3.3")
1818
testImplementation("org.apache.httpcomponents:httpclient:4.5.14")
1919
testImplementation("ch.qos.logback:logback-classic:1.4.14")
2020
testImplementation 'org.assertj:assertj-core:3.25.1'
21-
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.1")
2221
}
2322

2423
test {

modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQContainer.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ protected void configure() {
134134
setCommand(
135135
"-c",
136136
removeCommand +
137-
"cp -r '/opt/hivemq/temp-extensions/'* /opt/hivemq/extensions/ " +
138-
"; chmod -R 777 /opt/hivemq/extensions " +
139-
"&& /opt/docker-entrypoint.sh /opt/hivemq/bin/run.sh"
137+
"cp -r '/opt/hivemq/temp-extensions/'* /opt/hivemq/extensions/ ; " +
138+
"chmod -R 777 /opt/hivemq/extensions ; " +
139+
"/opt/docker-entrypoint.sh /opt/hivemq/bin/run.sh"
140140
);
141141
}
142142

modules/hivemq/src/test/java/org/testcontainers/hivemq/ContainerWithExtensionFromDirectoryIT.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package org.testcontainers.hivemq;
22

3+
import org.jetbrains.annotations.NotNull;
34
import org.junit.jupiter.api.Test;
45
import org.junit.jupiter.api.Timeout;
6+
import org.junit.jupiter.params.ParameterizedTest;
7+
import org.junit.jupiter.params.provider.ValueSource;
58
import org.slf4j.event.Level;
69
import org.testcontainers.hivemq.util.TestPublishModifiedUtil;
710
import org.testcontainers.utility.DockerImageName;
@@ -11,12 +14,18 @@
1114

1215
class ContainerWithExtensionFromDirectoryIT {
1316

14-
@Test
17+
@ParameterizedTest
18+
@ValueSource(
19+
strings = {
20+
"2020.1", // first version that provided a container image
21+
"2024.3", // version that runs the image as a non-root user by default
22+
}
23+
)
1524
@Timeout(value = 3, unit = TimeUnit.MINUTES)
16-
void test() throws Exception {
25+
void test(final @NotNull String hivemqCeTag) throws Exception {
1726
try (
1827
final HiveMQContainer hivemq = new HiveMQContainer(
19-
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
28+
DockerImageName.parse("hivemq/hivemq-ce").withTag(hivemqCeTag)
2029
)
2130
.withExtension(MountableFile.forClasspathResource("/modifier-extension"))
2231
.waitForExtension("Modifier Extension")
@@ -33,7 +42,7 @@ void test() throws Exception {
3342
void test_wrongDirectoryName() throws Exception {
3443
try (
3544
final HiveMQContainer hivemq = new HiveMQContainer(
36-
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
45+
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
3746
)
3847
.withExtension(MountableFile.forClasspathResource("/modifier-extension-wrong-name"))
3948
.waitForExtension("Modifier Extension")

modules/hivemq/src/test/java/org/testcontainers/hivemq/ContainerWithExtensionIT.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package org.testcontainers.hivemq;
22

3-
import org.junit.jupiter.api.Test;
3+
import org.jetbrains.annotations.NotNull;
44
import org.junit.jupiter.api.Timeout;
5+
import org.junit.jupiter.params.ParameterizedTest;
6+
import org.junit.jupiter.params.provider.ValueSource;
57
import org.testcontainers.hivemq.util.MyExtension;
68
import org.testcontainers.hivemq.util.TestPublishModifiedUtil;
79
import org.testcontainers.utility.DockerImageName;
@@ -11,9 +13,15 @@
1113

1214
class ContainerWithExtensionIT {
1315

14-
@Test
16+
@ParameterizedTest
17+
@ValueSource(
18+
strings = {
19+
"2020.1", // first version that provided a container image
20+
"2024.3", // version that runs the image as a non-root user by default
21+
}
22+
)
1523
@Timeout(value = 3, unit = TimeUnit.MINUTES)
16-
void test() throws Exception {
24+
void test(final @NotNull String hivemqCeTag) throws Exception {
1725
final HiveMQExtension hiveMQExtension = HiveMQExtension
1826
.builder()
1927
.id("extension-1")
@@ -24,7 +32,7 @@ void test() throws Exception {
2432

2533
try (
2634
final HiveMQContainer hivemq = new HiveMQContainer(
27-
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
35+
DockerImageName.parse("hivemq/hivemq-ce").withTag(hivemqCeTag)
2836
)
2937
.withHiveMQConfig(MountableFile.forClasspathResource("/inMemoryConfig.xml"))
3038
.waitForExtension(hiveMQExtension)

modules/hivemq/src/test/java/org/testcontainers/hivemq/ContainerWithExtensionSubclassIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void test() throws Exception {
2525

2626
try (
2727
final HiveMQContainer hivemq = new HiveMQContainer(
28-
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
28+
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
2929
)
3030
.waitForExtension(hiveMQExtension)
3131
.withExtension(hiveMQExtension)

modules/hivemq/src/test/java/org/testcontainers/hivemq/ContainerWithFileInExtensionHomeIT.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
import com.hivemq.extension.sdk.api.services.Services;
1010
import com.hivemq.extension.sdk.api.services.intializer.ClientInitializer;
1111
import org.jetbrains.annotations.NotNull;
12-
import org.junit.jupiter.api.Test;
1312
import org.junit.jupiter.api.Timeout;
13+
import org.junit.jupiter.params.ParameterizedTest;
14+
import org.junit.jupiter.params.provider.ValueSource;
1415
import org.testcontainers.hivemq.util.TestPublishModifiedUtil;
1516
import org.testcontainers.utility.DockerImageName;
1617
import org.testcontainers.utility.MountableFile;
@@ -22,9 +23,15 @@
2223

2324
class ContainerWithFileInExtensionHomeIT {
2425

25-
@Test
26+
@ParameterizedTest
27+
@ValueSource(
28+
strings = {
29+
"2020.1", // first version that provided a container image
30+
"2024.3", // version that runs the image as a non-root user by default
31+
}
32+
)
2633
@Timeout(value = 3, unit = TimeUnit.MINUTES)
27-
void test() throws Exception {
34+
void test(final @NotNull String hivemqCeTag) throws Exception {
2835
final HiveMQExtension hiveMQExtension = HiveMQExtension
2936
.builder()
3037
.id("extension-1")
@@ -35,7 +42,7 @@ void test() throws Exception {
3542

3643
try (
3744
final HiveMQContainer hivemq = new HiveMQContainer(
38-
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
45+
DockerImageName.parse("hivemq/hivemq-ce").withTag(hivemqCeTag)
3946
)
4047
.withHiveMQConfig(MountableFile.forClasspathResource("/inMemoryConfig.xml"))
4148
.withExtension(hiveMQExtension)

modules/hivemq/src/test/java/org/testcontainers/hivemq/ContainerWithFileInHomeIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void test() throws Exception {
3535

3636
try (
3737
final HiveMQContainer hivemq = new HiveMQContainer(
38-
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
38+
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
3939
)
4040
.withHiveMQConfig(MountableFile.forClasspathResource("/inMemoryConfig.xml"))
4141
.withExtension(hiveMQExtension)

modules/hivemq/src/test/java/org/testcontainers/hivemq/ContainerWithLicenseIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void test() throws Exception {
3535

3636
try (
3737
final HiveMQContainer hivemq = new HiveMQContainer(
38-
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
38+
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
3939
)
4040
.withHiveMQConfig(MountableFile.forClasspathResource("/inMemoryConfig.xml"))
4141
.withExtension(hiveMQExtension)

modules/hivemq/src/test/java/org/testcontainers/hivemq/CreateFileInCopiedDirectoryIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void test() throws Exception {
4747

4848
try (
4949
final HiveMQContainer hivemq = new HiveMQContainer(
50-
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
50+
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
5151
)
5252
.withHiveMQConfig(MountableFile.forClasspathResource("/inMemoryConfig.xml"))
5353
.withExtension(extension)

modules/hivemq/src/test/java/org/testcontainers/hivemq/CreateFileInExtensionDirectoryIT.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
import com.hivemq.extension.sdk.api.services.Services;
1010
import com.hivemq.extension.sdk.api.services.intializer.ClientInitializer;
1111
import org.jetbrains.annotations.NotNull;
12-
import org.junit.jupiter.api.Test;
1312
import org.junit.jupiter.api.Timeout;
13+
import org.junit.jupiter.params.ParameterizedTest;
14+
import org.junit.jupiter.params.provider.ValueSource;
1415
import org.testcontainers.hivemq.util.TestPublishModifiedUtil;
1516
import org.testcontainers.utility.DockerImageName;
1617
import org.testcontainers.utility.MountableFile;
@@ -23,9 +24,15 @@
2324

2425
class CreateFileInExtensionDirectoryIT {
2526

26-
@Test
27+
@ParameterizedTest
28+
@ValueSource(
29+
strings = {
30+
"2020.1", // first version that provided a container image
31+
"2024.3", // version that runs the image as a non-root user by default
32+
}
33+
)
2734
@Timeout(value = 3, unit = TimeUnit.MINUTES)
28-
void test() throws Exception {
35+
void test(final @NotNull String hivemqCeTag) throws Exception {
2936
final HiveMQExtension hiveMQExtension = HiveMQExtension
3037
.builder()
3138
.id("extension-1")
@@ -36,7 +43,7 @@ void test() throws Exception {
3643

3744
try (
3845
final HiveMQContainer hivemq = new HiveMQContainer(
39-
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
46+
DockerImageName.parse("hivemq/hivemq-ce").withTag(hivemqCeTag)
4047
)
4148
.withHiveMQConfig(MountableFile.forClasspathResource("/inMemoryConfig.xml"))
4249
.waitForExtension(hiveMQExtension)

modules/hivemq/src/test/java/org/testcontainers/hivemq/HiveMQTestContainerCore.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class HiveMQTestContainerCore {
1717

1818
@NotNull
19-
final HiveMQContainer container = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3"));
19+
final HiveMQContainer container = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3"));
2020

2121
@TempDir
2222
File tempDir;

modules/hivemq/src/test/java/org/testcontainers/hivemq/docs/DemoExtensionTestsIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class DemoExtensionTestsIT {
3838

3939
@Container
4040
final HiveMQContainer hivemqWithClasspathExtension = new HiveMQContainer(
41-
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
41+
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
4242
)
4343
.waitForExtension(hiveMQEClasspathxtension)
4444
.withExtension(hiveMQEClasspathxtension)

modules/hivemq/src/test/java/org/testcontainers/hivemq/docs/DemoFilesIT.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DemoFilesIT {
1919

2020
// hivemqHome {
2121
final HiveMQContainer hivemqFileInHome = new HiveMQContainer(
22-
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
22+
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
2323
)
2424
.withFileInHomeFolder(
2525
MountableFile.forHostPath("src/test/resources/additionalFile.txt"),
@@ -31,7 +31,7 @@ class DemoFilesIT {
3131
// extensionHome {
3232
@Container
3333
final HiveMQContainer hivemqFileInExtensionHome = new HiveMQContainer(
34-
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
34+
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
3535
)
3636
.withExtension(
3737
HiveMQExtension
@@ -52,7 +52,7 @@ class DemoFilesIT {
5252

5353
// withLicenses {
5454
@Container
55-
final HiveMQContainer hivemq = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3"))
55+
final HiveMQContainer hivemq = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3"))
5656
.withLicense(MountableFile.forHostPath("src/test/resources/myLicense.lic"))
5757
.withLicense(MountableFile.forHostPath("src/test/resources/myExtensionLicense.elic"));
5858

modules/hivemq/src/test/java/org/testcontainers/hivemq/docs/DemoHiveMQContainerIT.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DemoHiveMQContainerIT {
1818

1919
// ceVersion {
2020
@Container
21-
final HiveMQContainer hivemqCe = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3"))
21+
final HiveMQContainer hivemqCe = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3"))
2222
.withLogLevel(Level.DEBUG);
2323

2424
// }
@@ -43,7 +43,7 @@ class DemoHiveMQContainerIT {
4343

4444
// specificVersion {
4545
@Container
46-
final HiveMQContainer hivemqSpecificVersion = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce:2021.3"));
46+
final HiveMQContainer hivemqSpecificVersion = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce:2024.3"));
4747

4848
// }
4949

0 commit comments

Comments
 (0)