@@ -392,5 +392,46 @@ func TestKmeshctlDump(t *testing.T) {
392392 }
393393 }
394394
395+ func runAuthzCmd (args ... string ) (string , error ) {
396+ cmdArgs := append ([]string {"authz" }, args ... )
397+ cmd := exec .Command ("kmeshctl" , cmdArgs ... )
398+ out , err := cmd .CombinedOutput ()
399+ return string (out ), err
400+ }
395401
396-
402+ func TestKmeshctlAuthzEnableDisable (t * testing.T ) {
403+ pod := findKmeshPod (t )
404+ waitForPodRunning (t , pod )
405+
406+ t .Run ("enable-cluster" , func (t * testing.T ) {
407+ out , err := runAuthzCmd ("enable" )
408+ t .Logf ("Output of 'kmeshctl authz enable':\n %s" , out )
409+ if err != nil {
410+ t .Fatalf ("cluster-wide enable failed: %v" , err )
411+ }
412+ })
413+
414+ t .Run ("disable-cluster" , func (t * testing.T ) {
415+ out , err := runAuthzCmd ("disable" )
416+ t .Logf ("Output of 'kmeshctl authz disable':\n %s" , out )
417+ if err != nil {
418+ t .Fatalf ("cluster-wide disable failed: %v" , err )
419+ }
420+ })
421+
422+ t .Run ("enable-pod" , func (t * testing.T ) {
423+ out , err := runAuthzCmd ("enable" , pod )
424+ t .Logf ("Output of 'kmeshctl authz enable %s':\n %s" , pod , out )
425+ if err != nil {
426+ t .Fatalf ("per-pod enable failed: %v" , err )
427+ }
428+ })
429+
430+ t .Run ("disable-pod" , func (t * testing.T ) {
431+ out , err := runAuthzCmd ("disable" , pod )
432+ t .Logf ("Output of 'kmeshctl authz disable %s':\n %s" , pod , out )
433+ if err != nil {
434+ t .Fatalf ("per-pod disable failed: %v" , err )
435+ }
436+ })
437+ }
0 commit comments