Skip to content

Commit 4c6ec20

Browse files
committed
Add Azurite container to Azure module
- Fix configuration issue (to allow connections from any IP) Signed-off-by: Esta Nagy <[email protected]>
1 parent 55c7212 commit 4c6ec20

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

modules/azure/src/main/java/org/testcontainers/azure/AzuriteContainer.java

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ public class AzuriteContainer extends GenericContainer<AzuriteContainer> {
2424

2525
private static final String DEFAULT_HOST = "127.0.0.1";
2626

27+
private static final String ALLOW_ALL_CONNECTIONS = "0.0.0.0";
28+
2729
private static final int DEFAULT_BLOB_PORT = 10000;
2830

2931
private static final int DEFAULT_QUEUE_PORT = 10001;
3032

3133
private static final int DEFAULT_TABLE_PORT = 10002;
3234

3335
private static final String CONNECTION_STRING_FORMAT =
34-
"DefaultEndpointsProtocol=%s;AccountName=%s;AccountKey=%s;BlobEndpoint=%s://%s:%d/%s;QueueEndpoint=%s://%s:%d/%s;TableEndpoint=%s://%s:%d/%s;";
36+
"DefaultEndpointsProtocol=%s;AccountName=%s;AccountKey=%s;BlobEndpoint=%s://%s:%d/%s;QueueEndpoint=%s://%s:%d/%s;TableEndpoint=%s://%s:%d/%s;";
3537

3638
/**
3739
* The account name of the default credentials.
@@ -42,10 +44,10 @@ public class AzuriteContainer extends GenericContainer<AzuriteContainer> {
4244
* The account key of the default credentials.
4345
*/
4446
public static final String WELL_KNOWN_ACCOUNT_KEY =
45-
"Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==";
47+
"Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==";
4648

4749
private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse(
48-
"mcr.microsoft.com/azure-storage/azurite"
50+
"mcr.microsoft.com/azure-storage/azurite"
4951
);
5052

5153
private String host = DEFAULT_HOST;
@@ -141,30 +143,30 @@ public String getDefaultConnectionString() {
141143
public String getConnectionString(final String accountName, final String accountKey) {
142144
final String protocol = cert != null ? "https" : "http";
143145
return String.format(
144-
CONNECTION_STRING_FORMAT,
145-
protocol,
146-
accountName,
147-
accountKey,
148-
protocol,
149-
host,
150-
getMappedPort(DEFAULT_BLOB_PORT),
151-
accountName,
152-
protocol,
153-
host,
154-
getMappedPort(DEFAULT_QUEUE_PORT),
155-
accountName,
156-
protocol,
157-
host,
158-
getMappedPort(DEFAULT_TABLE_PORT),
159-
accountName
146+
CONNECTION_STRING_FORMAT,
147+
protocol,
148+
accountName,
149+
accountKey,
150+
protocol,
151+
host,
152+
getMappedPort(DEFAULT_BLOB_PORT),
153+
accountName,
154+
protocol,
155+
host,
156+
getMappedPort(DEFAULT_QUEUE_PORT),
157+
accountName,
158+
protocol,
159+
host,
160+
getMappedPort(DEFAULT_TABLE_PORT),
161+
accountName
160162
);
161163
}
162164

163165
String getCommandLine() {
164166
final StringBuilder args = new StringBuilder("azurite");
165-
args.append(" --blobHost ").append(host).append(" --blobPort ").append(DEFAULT_BLOB_PORT);
166-
args.append(" --queueHost ").append(host).append(" --queuePort ").append(DEFAULT_QUEUE_PORT);
167-
args.append(" --tableHost ").append(host).append(" --tablePort ").append(DEFAULT_TABLE_PORT);
167+
args.append(" --blobHost ").append(ALLOW_ALL_CONNECTIONS).append(" --blobPort ").append(DEFAULT_BLOB_PORT);
168+
args.append(" --queueHost ").append(ALLOW_ALL_CONNECTIONS).append(" --queuePort ").append(DEFAULT_QUEUE_PORT);
169+
args.append(" --tableHost ").append(ALLOW_ALL_CONNECTIONS).append(" --tablePort ").append(DEFAULT_TABLE_PORT);
168170
args.append(" --location ").append("/data");
169171
if (cert != null) {
170172
args.append(" --cert ").append("/cert").append(certExtension);

0 commit comments

Comments
 (0)