@@ -80,3 +80,49 @@ fn test_vhosts_delete() -> Result<(), Box<dyn std::error::Error>> {
8080
8181 Ok ( ( ) )
8282}
83+
84+ #[ test]
85+ fn test_vhosts_enable_deletion_protection ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
86+ let vh = "rabbitmqadmin.vhosts.test-deletion-protection-enable" ;
87+ run_succeeds ( [ "vhosts" , "delete" , "--name" , vh, "--idempotently" ] ) ;
88+
89+ run_succeeds ( [ "vhosts" , "declare" , "--name" , vh] ) ;
90+
91+ run_succeeds ( [ "vhosts" , "enable_deletion_protection" , "--name" , vh] ) ;
92+
93+ run_succeeds ( [ "vhosts" , "disable_deletion_protection" , "--name" , vh] ) ;
94+ run_succeeds ( [ "vhosts" , "delete" , "--name" , vh] ) ;
95+
96+ Ok ( ( ) )
97+ }
98+
99+ #[ test]
100+ fn test_vhosts_disable_deletion_protection ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
101+ let vh = "rabbitmqadmin.vhosts.test-deletion-protection-disable" ;
102+ run_succeeds ( [ "vhosts" , "delete" , "--name" , vh, "--idempotently" ] ) ;
103+
104+ run_succeeds ( [ "vhosts" , "declare" , "--name" , vh] ) ;
105+
106+ run_succeeds ( [ "vhosts" , "enable_deletion_protection" , "--name" , vh] ) ;
107+ run_succeeds ( [ "vhosts" , "disable_deletion_protection" , "--name" , vh] ) ;
108+
109+ run_succeeds ( [ "vhosts" , "delete" , "--name" , vh] ) ;
110+
111+ Ok ( ( ) )
112+ }
113+
114+ #[ test]
115+ fn test_vhosts_protected_vhost_cannot_be_deleted ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
116+ let vh = "rabbitmqadmin.vhosts.test-protected-cannot-delete" ;
117+ run_succeeds ( [ "vhosts" , "delete" , "--name" , vh, "--idempotently" ] ) ;
118+
119+ run_succeeds ( [ "vhosts" , "declare" , "--name" , vh] ) ;
120+ run_succeeds ( [ "vhosts" , "enable_deletion_protection" , "--name" , vh] ) ;
121+
122+ run_fails ( [ "vhosts" , "delete" , "--name" , vh] ) ;
123+
124+ run_succeeds ( [ "vhosts" , "disable_deletion_protection" , "--name" , vh] ) ;
125+ run_succeeds ( [ "vhosts" , "delete" , "--name" , vh] ) ;
126+
127+ Ok ( ( ) )
128+ }
0 commit comments