Skip to content

Commit 847fcda

Browse files
committed
Set loopback users back to initial value after test
(cherry picked from commit 46b245f)
1 parent 0b0cc0a commit 847fcda

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

Diff for: src/test/java/com/rabbitmq/client/test/functional/ConnectionRecovery.java

-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.rabbitmq.client.test.BrokerTestCase;
2424
import com.rabbitmq.client.test.TestUtils;
2525
import com.rabbitmq.tools.Host;
26-
import org.junit.jupiter.api.Disabled;
2726
import org.junit.jupiter.api.Test;
2827

2928
import java.io.IOException;
@@ -368,7 +367,6 @@ private void testClientNamedQueueRecoveryWith(String q, boolean noWait) throws I
368367
}
369368

370369
// bug 26552
371-
@Disabled
372370
@Test public void clientNamedTransientAutoDeleteQueueAndBindingRecovery() throws IOException, InterruptedException, TimeoutException {
373371
String q = UUID.randomUUID().toString();
374372
String x = "tmp-fanout";

Diff for: src/test/java/com/rabbitmq/client/test/server/LoopbackUsers.java

+17-5
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,26 @@ public class LoopbackUsers {
4848
@Test public void loopback() throws IOException, TimeoutException {
4949
if (!Host.isOnDocker()) {
5050
String addr = findRealIPAddress().getHostAddress();
51-
assertGuestFail(addr);
52-
Host.rabbitmqctl("eval 'application:set_env(rabbit, loopback_users, []).'");
53-
assertGuestSucceed(addr);
54-
Host.rabbitmqctl("eval 'application:set_env(rabbit, loopback_users, [<<\"guest\">>]).'");
55-
assertGuestFail(addr);
51+
String initialValue = getLoopbackUsers();
52+
try {
53+
setLoopbackUsers("[]");
54+
assertGuestSucceed(addr);
55+
setLoopbackUsers("[<<\"guest\">>]");
56+
assertGuestFail(addr);
57+
} finally {
58+
setLoopbackUsers(initialValue);
59+
}
5660
}
5761
}
5862

63+
private static String getLoopbackUsers() throws IOException {
64+
return Host.rabbitmqctl("eval '{ok, V} = application:get_env(rabbit, loopback_users), V.'").output();
65+
}
66+
67+
private static void setLoopbackUsers(String value) throws IOException {
68+
Host.rabbitmqctl(String.format("eval 'application:set_env(rabbit, loopback_users, %s).'", value));
69+
}
70+
5971
private void assertGuestSucceed(String addr) throws IOException, TimeoutException {
6072
succeedConnect("guest", addr);
6173
succeedConnect("guest", "localhost");

Diff for: src/test/java/com/rabbitmq/tools/Host.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static ProcessState executeCommand(String command) throws IOException
8080
return new ProcessState(pr, inputState, errorState);
8181
}
8282

83-
static class ProcessState {
83+
public static class ProcessState {
8484

8585
private final Process process;
8686
private final InputStreamPumpState inputState;
@@ -93,7 +93,7 @@ static class ProcessState {
9393
this.errorState = errorState;
9494
}
9595

96-
private String output() {
96+
public String output() {
9797
return inputState.buffer.toString();
9898
}
9999

0 commit comments

Comments
 (0)