Skip to content

Commit 1c52d3c

Browse files
committed
fix
1 parent 6c38eb0 commit 1c52d3c

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

src/test/java/org/apache/skywalking/banyandb/v1/client/BanyanDBAuthTest.java

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
import org.testcontainers.utility.MountableFile;
3030

3131
import java.io.IOException;
32+
import java.nio.file.Files;
33+
import java.nio.file.Path;
34+
import java.nio.file.Paths;
35+
import java.nio.file.attribute.PosixFilePermissions;
3236
import java.util.List;
3337
import java.util.concurrent.TimeUnit;
3438

@@ -46,18 +50,29 @@ public class BanyanDBAuthTest {
4650
protected static final int HTTP_PORT = 17913;
4751

4852
@Rule
49-
public GenericContainer<?> banyanDB = new GenericContainer<>(DockerImageName.parse(IMAGE))
50-
.withCopyFileToContainer(
51-
MountableFile.forClasspathResource("config.yaml"),
52-
"/tmp/bydb_server_config.yaml"
53-
)
54-
.withCommand("sh", "-c",
55-
"chmod 600 /tmp/bydb_server_config.yaml && exec standalone " +
56-
"--auth-config-file /tmp/bydb_server_config.yaml " +
57-
"--enable-health-auth false"
58-
)
59-
.withExposedPorts(GRPC_PORT, HTTP_PORT)
60-
.waitingFor(Wait.forHttp("/api/healthz").forPort(HTTP_PORT));
53+
public GenericContainer<?> banyanDB;
54+
55+
public BanyanDBAuthTest() throws Exception {
56+
// Step 1: prepare config file with 0600 permissions
57+
Path tempConfigPath = Files.createTempFile("bydb_server_config", ".yaml");
58+
Files.write(tempConfigPath, Files.readAllBytes(
59+
Paths.get(getClass().getClassLoader().getResource("config.yaml").toURI()))
60+
);
61+
Files.setPosixFilePermissions(tempConfigPath, PosixFilePermissions.fromString("rw-------"));
62+
63+
// Step 2: create container
64+
banyanDB = new GenericContainer<>(DockerImageName.parse(IMAGE))
65+
.withCopyFileToContainer(
66+
MountableFile.forHostPath(tempConfigPath),
67+
"/tmp/bydb_server_config.yaml"
68+
)
69+
.withCommand("standalone",
70+
"--auth-config-file", "/tmp/bydb_server_config.yaml",
71+
"--enable-health-auth", "false"
72+
)
73+
.withExposedPorts(GRPC_PORT, HTTP_PORT)
74+
.waitingFor(Wait.forHttp("/api/healthz").forPort(HTTP_PORT));
75+
}
6176

6277
@Test
6378
public void testAuthWithCorrect() throws IOException {

0 commit comments

Comments
 (0)