1717
1818package org .apache .dolphinscheduler .plugin .registry .zookeeper ;
1919
20+ import static org .apache .zookeeper .ZooDefs .Ids .OPEN_ACL_UNSAFE ;
21+
2022import org .apache .dolphinscheduler .plugin .registry .RegistryTestCase ;
2123
2224import org .apache .zookeeper .ZooDefs ;
2729import org .apache .zookeeper .server .DumbWatcher ;
2830import org .apache .zookeeper .server .auth .DigestAuthenticationProvider ;
2931
32+ import java .nio .charset .StandardCharsets ;
3033import java .util .Collections ;
3134import java .util .stream .Stream ;
3235
3740import org .springframework .beans .factory .annotation .Autowired ;
3841import org .springframework .boot .autoconfigure .SpringBootApplication ;
3942import org .springframework .boot .test .context .SpringBootTest ;
43+ import org .springframework .test .context .ActiveProfiles ;
4044import org .testcontainers .containers .GenericContainer ;
4145import org .testcontainers .containers .Network ;
4246import org .testcontainers .lifecycle .Startables ;
4347import org .testcontainers .utility .DockerImageName ;
4448
49+ @ ActiveProfiles ("digest" )
4550@ SpringBootTest (classes = ZookeeperRegistryProperties .class )
4651@ SpringBootApplication (scanBasePackageClasses = ZookeeperRegistryProperties .class )
4752public class ZookeeperRegistryDigestTestCase extends RegistryTestCase <ZookeeperRegistry > {
@@ -67,6 +72,10 @@ public static void setupRootACLForDigest(final ZooKeeper zk) throws Exception {
6772 zk .setACL ("/" , Collections .singletonList (acl ), -1 );
6873 }
6974
75+ public static void resetRootACL (final ZooKeeper zk ) throws Exception {
76+ zk .setACL ("/" , OPEN_ACL_UNSAFE , -1 );
77+ }
78+
7079 @ SneakyThrows
7180 @ BeforeAll
7281 public static void setUpTestingServer () {
@@ -78,7 +87,6 @@ public static void setUpTestingServer() {
7887 System .setProperty ("registry.zookeeper.connect-string" , "localhost:" + zookeeperContainer .getMappedPort (2181 ));
7988 zk = new ZooKeeper ("localhost:" + zookeeperContainer .getMappedPort (2181 ),
8089 30000 , new DumbWatcher (), new ZKClientConfig ());
81- System .setProperty ("registry.zookeeper.authorization.digest" , ID_PASSWORD );
8290 setupRootACLForDigest (zk );
8391 }
8492
@@ -91,6 +99,8 @@ public ZookeeperRegistry createRegistry() {
9199 @ SneakyThrows
92100 @ AfterAll
93101 public static void tearDownTestingServer () {
102+ zk .addAuthInfo ("digest" , ID_PASSWORD .getBytes (StandardCharsets .UTF_8 ));
103+ resetRootACL (zk );
94104 zk .close ();
95105 zookeeperContainer .close ();
96106 }
0 commit comments