@@ -653,3 +653,347 @@ async fn test_cloud_list_all_subscriptions() {
653653 . stdout ( predicate:: str:: contains ( "production" ) )
654654 . stdout ( predicate:: str:: contains ( "staging" ) ) ;
655655}
656+
657+ #[ tokio:: test]
658+ async fn test_enterprise_node_operations ( ) {
659+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
660+ let mock_server = MockServer :: start ( ) . await ;
661+
662+ create_enterprise_profile ( & temp_dir, & mock_server. uri ( ) ) . unwrap ( ) ;
663+
664+ // Mock nodes endpoint
665+ Mock :: given ( method ( "GET" ) )
666+ . and ( path ( "/v1/nodes/1" ) )
667+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( json ! ( {
668+ "uid" : 1 ,
669+ "addr" : "10.0.0.1" ,
670+ "status" : "active" ,
671+ "total_memory" : 16000000000_u64
672+ } ) ) )
673+ . expect ( 1 )
674+ . mount ( & mock_server)
675+ . await ;
676+
677+ test_cmd ( & temp_dir)
678+ . arg ( "api" )
679+ . arg ( "enterprise" )
680+ . arg ( "get" )
681+ . arg ( "/v1/nodes/1" )
682+ . assert ( )
683+ . success ( )
684+ . stdout ( predicate:: str:: contains ( "10.0.0.1" ) )
685+ . stdout ( predicate:: str:: contains ( "active" ) ) ;
686+ }
687+
688+ #[ tokio:: test]
689+ async fn test_cloud_vpc_peering_endpoints ( ) {
690+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
691+ let mock_server = MockServer :: start ( ) . await ;
692+
693+ create_cloud_profile ( & temp_dir, & mock_server. uri ( ) ) . unwrap ( ) ;
694+
695+ // Mock VPC peering list endpoint
696+ Mock :: given ( method ( "GET" ) )
697+ . and ( path ( "/subscriptions/100/peerings" ) )
698+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( json ! ( {
699+ "peerings" : [
700+ {
701+ "id" : 1 ,
702+ "provider" : "AWS" ,
703+ "region" : "us-east-1" ,
704+ "status" : "active"
705+ }
706+ ]
707+ } ) ) )
708+ . expect ( 1 )
709+ . mount ( & mock_server)
710+ . await ;
711+
712+ test_cmd ( & temp_dir)
713+ . arg ( "api" )
714+ . arg ( "cloud" )
715+ . arg ( "get" )
716+ . arg ( "/subscriptions/100/peerings" )
717+ . assert ( )
718+ . success ( )
719+ . stdout ( predicate:: str:: contains ( "AWS" ) )
720+ . stdout ( predicate:: str:: contains ( "us-east-1" ) ) ;
721+ }
722+
723+ #[ tokio:: test]
724+ async fn test_enterprise_backup_operations ( ) {
725+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
726+ let mock_server = MockServer :: start ( ) . await ;
727+
728+ create_enterprise_profile ( & temp_dir, & mock_server. uri ( ) ) . unwrap ( ) ;
729+
730+ // Mock backup export endpoint
731+ Mock :: given ( method ( "POST" ) )
732+ . and ( path ( "/v1/bdbs/1/backup" ) )
733+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( json ! ( {
734+ "uid" : "backup-123" ,
735+ "status" : "started" ,
736+ "bdb_uid" : 1
737+ } ) ) )
738+ . expect ( 1 )
739+ . mount ( & mock_server)
740+ . await ;
741+
742+ test_cmd ( & temp_dir)
743+ . arg ( "api" )
744+ . arg ( "enterprise" )
745+ . arg ( "post" )
746+ . arg ( "/v1/bdbs/1/backup" )
747+ . arg ( "--data" )
748+ . arg ( r#"{"location":"/tmp/backup"}"# )
749+ . assert ( )
750+ . success ( )
751+ . stdout ( predicate:: str:: contains ( "backup-123" ) ) ;
752+ }
753+
754+ #[ tokio:: test]
755+ async fn test_cloud_account_information ( ) {
756+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
757+ let mock_server = MockServer :: start ( ) . await ;
758+
759+ create_cloud_profile ( & temp_dir, & mock_server. uri ( ) ) . unwrap ( ) ;
760+
761+ // Mock account endpoint
762+ Mock :: given ( method ( "GET" ) )
763+ . and ( path ( "/account" ) )
764+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( json ! ( {
765+ "id" : 2034806 ,
766+ "name" : "Test Account" ,
767+ "key" : {
768+ "name" : "test-key" ,
769+ "accountId" : 2034806
770+ }
771+ } ) ) )
772+ . expect ( 1 )
773+ . mount ( & mock_server)
774+ . await ;
775+
776+ test_cmd ( & temp_dir)
777+ . arg ( "api" )
778+ . arg ( "cloud" )
779+ . arg ( "get" )
780+ . arg ( "/account" )
781+ . assert ( )
782+ . success ( )
783+ . stdout ( predicate:: str:: contains ( "Test Account" ) )
784+ . stdout ( predicate:: str:: contains ( "2034806" ) ) ;
785+ }
786+
787+ #[ tokio:: test]
788+ async fn test_enterprise_redis_acl_operations ( ) {
789+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
790+ let mock_server = MockServer :: start ( ) . await ;
791+
792+ create_enterprise_profile ( & temp_dir, & mock_server. uri ( ) ) . unwrap ( ) ;
793+
794+ // Mock Redis ACL list
795+ Mock :: given ( method ( "GET" ) )
796+ . and ( path ( "/v1/redis_acls" ) )
797+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( json ! ( [
798+ {
799+ "uid" : 1 ,
800+ "name" : "default-acl" ,
801+ "acl" : "+@all"
802+ } ,
803+ {
804+ "uid" : 2 ,
805+ "name" : "readonly-acl" ,
806+ "acl" : "+@read"
807+ }
808+ ] ) ) )
809+ . expect ( 1 )
810+ . mount ( & mock_server)
811+ . await ;
812+
813+ test_cmd ( & temp_dir)
814+ . arg ( "api" )
815+ . arg ( "enterprise" )
816+ . arg ( "get" )
817+ . arg ( "/v1/redis_acls" )
818+ . assert ( )
819+ . success ( )
820+ . stdout ( predicate:: str:: contains ( "default-acl" ) )
821+ . stdout ( predicate:: str:: contains ( "readonly-acl" ) ) ;
822+ }
823+
824+ #[ tokio:: test]
825+ async fn test_cloud_database_modules ( ) {
826+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
827+ let mock_server = MockServer :: start ( ) . await ;
828+
829+ create_cloud_profile ( & temp_dir, & mock_server. uri ( ) ) . unwrap ( ) ;
830+
831+ // Mock database with modules
832+ Mock :: given ( method ( "GET" ) )
833+ . and ( path ( "/subscriptions/123/databases/456" ) )
834+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( json ! ( {
835+ "databaseId" : 456 ,
836+ "name" : "redis-with-modules" ,
837+ "modules" : [
838+ {
839+ "name" : "RedisJSON" ,
840+ "version" : "2.6"
841+ } ,
842+ {
843+ "name" : "RediSearch" ,
844+ "version" : "2.8"
845+ }
846+ ]
847+ } ) ) )
848+ . expect ( 1 )
849+ . mount ( & mock_server)
850+ . await ;
851+
852+ test_cmd ( & temp_dir)
853+ . arg ( "api" )
854+ . arg ( "cloud" )
855+ . arg ( "get" )
856+ . arg ( "/subscriptions/123/databases/456" )
857+ . assert ( )
858+ . success ( )
859+ . stdout ( predicate:: str:: contains ( "RedisJSON" ) )
860+ . stdout ( predicate:: str:: contains ( "RediSearch" ) ) ;
861+ }
862+
863+ #[ tokio:: test]
864+ async fn test_enterprise_crdb_operations ( ) {
865+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
866+ let mock_server = MockServer :: start ( ) . await ;
867+
868+ create_enterprise_profile ( & temp_dir, & mock_server. uri ( ) ) . unwrap ( ) ;
869+
870+ // Mock CRDB (Active-Active) list
871+ Mock :: given ( method ( "GET" ) )
872+ . and ( path ( "/v1/crdbs" ) )
873+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( json ! ( [
874+ {
875+ "guid" : "crdb-guid-1" ,
876+ "name" : "geo-distributed-db" ,
877+ "replication" : true ,
878+ "instances" : [
879+ { "cluster" : { "url" : "cluster1.example.com" } } ,
880+ { "cluster" : { "url" : "cluster2.example.com" } }
881+ ]
882+ }
883+ ] ) ) )
884+ . expect ( 1 )
885+ . mount ( & mock_server)
886+ . await ;
887+
888+ test_cmd ( & temp_dir)
889+ . arg ( "api" )
890+ . arg ( "enterprise" )
891+ . arg ( "get" )
892+ . arg ( "/v1/crdbs" )
893+ . assert ( )
894+ . success ( )
895+ . stdout ( predicate:: str:: contains ( "geo-distributed-db" ) )
896+ . stdout ( predicate:: str:: contains ( "cluster1.example.com" ) ) ;
897+ }
898+
899+ #[ tokio:: test]
900+ async fn test_cloud_payment_methods ( ) {
901+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
902+ let mock_server = MockServer :: start ( ) . await ;
903+
904+ create_cloud_profile ( & temp_dir, & mock_server. uri ( ) ) . unwrap ( ) ;
905+
906+ // Mock payment methods endpoint
907+ Mock :: given ( method ( "GET" ) )
908+ . and ( path ( "/payment-methods" ) )
909+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( json ! ( {
910+ "paymentMethods" : [
911+ {
912+ "id" : 1 ,
913+ "type" : "credit-card" ,
914+ "last4" : "4242"
915+ }
916+ ]
917+ } ) ) )
918+ . expect ( 1 )
919+ . mount ( & mock_server)
920+ . await ;
921+
922+ test_cmd ( & temp_dir)
923+ . arg ( "api" )
924+ . arg ( "cloud" )
925+ . arg ( "get" )
926+ . arg ( "/payment-methods" )
927+ . assert ( )
928+ . success ( )
929+ . stdout ( predicate:: str:: contains ( "credit-card" ) )
930+ . stdout ( predicate:: str:: contains ( "4242" ) ) ;
931+ }
932+
933+ #[ tokio:: test]
934+ async fn test_enterprise_license_info ( ) {
935+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
936+ let mock_server = MockServer :: start ( ) . await ;
937+
938+ create_enterprise_profile ( & temp_dir, & mock_server. uri ( ) ) . unwrap ( ) ;
939+
940+ // Mock license endpoint
941+ Mock :: given ( method ( "GET" ) )
942+ . and ( path ( "/v1/license" ) )
943+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( json ! ( {
944+ "license" : "valid" ,
945+ "activation_date" : "2024-01-01" ,
946+ "expiration_date" : "2025-12-31" ,
947+ "shards_limit" : 100
948+ } ) ) )
949+ . expect ( 1 )
950+ . mount ( & mock_server)
951+ . await ;
952+
953+ test_cmd ( & temp_dir)
954+ . arg ( "api" )
955+ . arg ( "enterprise" )
956+ . arg ( "get" )
957+ . arg ( "/v1/license" )
958+ . assert ( )
959+ . success ( )
960+ . stdout ( predicate:: str:: contains ( "valid" ) )
961+ . stdout ( predicate:: str:: contains ( "shards_limit" ) ) ;
962+ }
963+
964+ #[ tokio:: test]
965+ async fn test_cloud_maintenance_windows ( ) {
966+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
967+ let mock_server = MockServer :: start ( ) . await ;
968+
969+ create_cloud_profile ( & temp_dir, & mock_server. uri ( ) ) . unwrap ( ) ;
970+
971+ // Mock maintenance window update
972+ Mock :: given ( method ( "PUT" ) )
973+ . and ( path ( "/subscriptions/123/maintenance" ) )
974+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( json ! ( {
975+ "subscriptionId" : 123 ,
976+ "maintenanceWindows" : [
977+ {
978+ "mode" : "weekly" ,
979+ "startHour" : 2 ,
980+ "durationInHours" : 4
981+ }
982+ ]
983+ } ) ) )
984+ . expect ( 1 )
985+ . mount ( & mock_server)
986+ . await ;
987+
988+ test_cmd ( & temp_dir)
989+ . arg ( "api" )
990+ . arg ( "cloud" )
991+ . arg ( "put" )
992+ . arg ( "/subscriptions/123/maintenance" )
993+ . arg ( "--data" )
994+ . arg ( r#"{"mode":"weekly","startHour":2}"# )
995+ . assert ( )
996+ . success ( )
997+ . stdout ( predicate:: str:: contains ( "maintenanceWindows" ) )
998+ . stdout ( predicate:: str:: contains ( "weekly" ) ) ;
999+ }
0 commit comments