@@ -775,6 +775,158 @@ integTest('cdk diff --fail with multiple stack exits with if any of the stacks c
775
775
await expect ( fixture . cdk ( [ 'diff' , '--fail' , fixture . fullStackName ( 'test-1' ) , fixture . fullStackName ( 'test-2' ) ] ) ) . rejects . toThrow ( 'exited with error' ) ;
776
776
} ) ) ;
777
777
778
+ integTest ( 'cdk diff --security-only successfully outputs sso-permission-set-without-managed-policy information' , withDefaultFixture ( async ( fixture ) => {
779
+ const diff = await fixture . cdk (
780
+ [ 'diff' , '--security-only' , fixture . fullStackName ( 'sso-perm-set-without-managed-policy' ) ] ,
781
+ ) ;
782
+ `┌───┬──────────────────────────────────────────┬──────────────────────────────────┬────────────────────┬───────────────────────────────────┬─────────────────────────────────┐
783
+ │ │ Resource │ InstanceArn │ PermissionSet name │ PermissionsBoundary │ CustomerManagedPolicyReferences │
784
+ ├───┼──────────────────────────────────────────┼──────────────────────────────────┼────────────────────┼───────────────────────────────────┼─────────────────────────────────┤
785
+ │ + │\${permission-set-without-managed-policy} │ arn:aws:sso:::instance/testvalue │ testName │ CustomerManagedPolicyReference: { │ │
786
+ │ │ │ │ │ Name: why, Path: /how/ │ │
787
+ │ │ │ │ │ } │ │
788
+ ` ;
789
+ expect ( diff ) . toContain ( 'Resource' ) ;
790
+ expect ( diff ) . toContain ( 'permission-set-without-managed-policy' ) ;
791
+
792
+ expect ( diff ) . toContain ( 'InstanceArn' ) ;
793
+ expect ( diff ) . toContain ( 'arn:aws:sso:::instance/testvalue' ) ;
794
+
795
+ expect ( diff ) . toContain ( 'PermissionSet name' ) ;
796
+ expect ( diff ) . toContain ( 'testName' ) ;
797
+
798
+ expect ( diff ) . toContain ( 'PermissionsBoundary' ) ;
799
+ expect ( diff ) . toContain ( 'CustomerManagedPolicyReference: {' ) ;
800
+ expect ( diff ) . toContain ( 'Name: why, Path: /how/' ) ;
801
+ expect ( diff ) . toContain ( '}' ) ;
802
+
803
+ expect ( diff ) . toContain ( 'CustomerManagedPolicyReferences' ) ;
804
+ } ) ) ;
805
+
806
+ integTest ( 'cdk diff --security-only successfully outputs sso-permission-set-with-managed-policy information' , withDefaultFixture ( async ( fixture ) => {
807
+ const diff = await fixture . cdk (
808
+ [ 'diff' , '--security-only' , fixture . fullStackName ( 'sso-perm-set-with-managed-policy' ) ] ,
809
+ ) ;
810
+ `┌───┬──────────────────────────────────────────┬──────────────────────────────────┬────────────────────┬───────────────────────────────────────────────────────────────┬─────────────────────────────────┐
811
+ │ │ Resource │ InstanceArn │ PermissionSet name │ PermissionsBoundary │ CustomerManagedPolicyReferences │
812
+ ├───┼──────────────────────────────────────────┼──────────────────────────────────┼────────────────────┼───────────────────────────────────────────────────────────────┼─────────────────────────────────┤
813
+ │ + │\${permission-set-with-managed-policy} │ arn:aws:sso:::instance/testvalue │ niceWork │ ManagedPolicyArn: arn:aws:iam::aws:policy/AdministratorAccess │ Name: forSSO, Path: │
814
+ ` ;
815
+
816
+ expect ( diff ) . toContain ( 'Resource' ) ;
817
+ expect ( diff ) . toContain ( 'permission-set-with-managed-policy' ) ;
818
+
819
+ expect ( diff ) . toContain ( 'InstanceArn' ) ;
820
+ expect ( diff ) . toContain ( 'arn:aws:sso:::instance/testvalue' ) ;
821
+
822
+ expect ( diff ) . toContain ( 'PermissionSet name' ) ;
823
+ expect ( diff ) . toContain ( 'niceWork' ) ;
824
+
825
+ expect ( diff ) . toContain ( 'PermissionsBoundary' ) ;
826
+ expect ( diff ) . toContain ( 'ManagedPolicyArn: arn:aws:iam::aws:policy/AdministratorAccess' ) ;
827
+
828
+ expect ( diff ) . toContain ( 'CustomerManagedPolicyReferences' ) ;
829
+ expect ( diff ) . toContain ( 'Name: forSSO, Path:' ) ;
830
+ } ) ) ;
831
+
832
+ integTest ( 'cdk diff --security-only successfully outputs sso-assignment information' , withDefaultFixture ( async ( fixture ) => {
833
+ const diff = await fixture . cdk (
834
+ [ 'diff' , '--security-only' , fixture . fullStackName ( 'sso-assignment' ) ] ,
835
+ ) ;
836
+ `┌───┬───────────────┬──────────────────────────────────┬─────────────────────────┬──────────────────────────────┬───────────────┬──────────────┬─────────────┐
837
+ │ │ Resource │ InstanceArn │ PermissionSetArn │ PrincipalId │ PrincipalType │ TargetId │ TargetType │
838
+ ├───┼───────────────┼──────────────────────────────────┼─────────────────────────┼──────────────────────────────┼───────────────┼──────────────┼─────────────┤
839
+ │ + │\${assignment} │ arn:aws:sso:::instance/testvalue │ arn:aws:sso:::testvalue │ 11111111-2222-3333-4444-test │ USER │ 111111111111 │ AWS_ACCOUNT │
840
+ └───┴───────────────┴──────────────────────────────────┴─────────────────────────┴──────────────────────────────┴───────────────┴──────────────┴─────────────┘
841
+ ` ;
842
+ expect ( diff ) . toContain ( 'Resource' ) ;
843
+ expect ( diff ) . toContain ( 'assignment' ) ;
844
+
845
+ expect ( diff ) . toContain ( 'InstanceArn' ) ;
846
+ expect ( diff ) . toContain ( 'arn:aws:sso:::instance/testvalue' ) ;
847
+
848
+ expect ( diff ) . toContain ( 'PermissionSetArn' ) ;
849
+ expect ( diff ) . toContain ( 'arn:aws:sso:::testvalue' ) ;
850
+
851
+ expect ( diff ) . toContain ( 'PrincipalId' ) ;
852
+ expect ( diff ) . toContain ( '11111111-2222-3333-4444-test' ) ;
853
+
854
+ expect ( diff ) . toContain ( 'PrincipalType' ) ;
855
+ expect ( diff ) . toContain ( 'USER' ) ;
856
+
857
+ expect ( diff ) . toContain ( 'TargetId' ) ;
858
+ expect ( diff ) . toContain ( '111111111111' ) ;
859
+
860
+ expect ( diff ) . toContain ( 'TargetType' ) ;
861
+ expect ( diff ) . toContain ( 'AWS_ACCOUNT' ) ;
862
+ } ) ) ;
863
+
864
+ integTest ( 'cdk diff --security-only successfully outputs sso-access-control information' , withDefaultFixture ( async ( fixture ) => {
865
+ const diff = await fixture . cdk (
866
+ [ 'diff' , '--security-only' , fixture . fullStackName ( 'sso-access-control' ) ] ,
867
+ ) ;
868
+ `┌───┬────────────────────────────────┬────────────────────────┬─────────────────────────────────┐
869
+ │ │ Resource │ InstanceArn │ AccessControlAttributes │
870
+ ├───┼────────────────────────────────┼────────────────────────┼─────────────────────────────────┤
871
+ │ + │\${instanceAccessControlConfig} │ arn:aws:test:testvalue │ Key: first, Values: [a] │
872
+ │ │ │ │ Key: second, Values: [b] │
873
+ │ │ │ │ Key: third, Values: [c] │
874
+ │ │ │ │ Key: fourth, Values: [d] │
875
+ │ │ │ │ Key: fifth, Values: [e] │
876
+ │ │ │ │ Key: sixth, Values: [f] │
877
+ └───┴────────────────────────────────┴────────────────────────┴─────────────────────────────────┘
878
+ ` ;
879
+ expect ( diff ) . toContain ( 'Resource' ) ;
880
+ expect ( diff ) . toContain ( 'instanceAccessControlConfig' ) ;
881
+
882
+ expect ( diff ) . toContain ( 'InstanceArn' ) ;
883
+ expect ( diff ) . toContain ( 'arn:aws:sso:::instance/testvalue' ) ;
884
+
885
+ expect ( diff ) . toContain ( 'AccessControlAttributes' ) ;
886
+ expect ( diff ) . toContain ( 'Key: first, Values: [a]' ) ;
887
+ expect ( diff ) . toContain ( 'Key: second, Values: [b]' ) ;
888
+ expect ( diff ) . toContain ( 'Key: third, Values: [c]' ) ;
889
+ expect ( diff ) . toContain ( 'Key: fourth, Values: [d]' ) ;
890
+ expect ( diff ) . toContain ( 'Key: fifth, Values: [e]' ) ;
891
+ expect ( diff ) . toContain ( 'Key: sixth, Values: [f]' ) ;
892
+ } ) ) ;
893
+
894
+ integTest ( 'cdk diff --security-only --fail exits when security diff for sso access control config' , withDefaultFixture ( async ( fixture ) => {
895
+ await expect (
896
+ fixture . cdk (
897
+ [ 'diff' , '--security-only' , '--fail' , fixture . fullStackName ( 'sso-access-control' ) ] ,
898
+ ) ,
899
+ ) . rejects
900
+ . toThrow ( 'exited with error' ) ;
901
+ } ) ) ;
902
+
903
+ integTest ( 'cdk diff --security-only --fail exits when security diff for sso-perm-set-without-managed-policy' , withDefaultFixture ( async ( fixture ) => {
904
+ await expect (
905
+ fixture . cdk (
906
+ [ 'diff' , '--security-only' , '--fail' , fixture . fullStackName ( 'sso-perm-set-without-managed-policy' ) ] ,
907
+ ) ,
908
+ ) . rejects
909
+ . toThrow ( 'exited with error' ) ;
910
+ } ) ) ;
911
+
912
+ integTest ( 'cdk diff --security-only --fail exits when security diff for sso-perm-set-with-managed-policy' , withDefaultFixture ( async ( fixture ) => {
913
+ await expect (
914
+ fixture . cdk (
915
+ [ 'diff' , '--security-only' , '--fail' , fixture . fullStackName ( 'sso-perm-set-with-managed-policy' ) ] ,
916
+ ) ,
917
+ ) . rejects
918
+ . toThrow ( 'exited with error' ) ;
919
+ } ) ) ;
920
+
921
+ integTest ( 'cdk diff --security-only --fail exits when security diff for sso-assignment' , withDefaultFixture ( async ( fixture ) => {
922
+ await expect (
923
+ fixture . cdk (
924
+ [ 'diff' , '--security-only' , '--fail' , fixture . fullStackName ( 'sso-assignment' ) ] ,
925
+ ) ,
926
+ ) . rejects
927
+ . toThrow ( 'exited with error' ) ;
928
+ } ) ) ;
929
+
778
930
integTest ( 'cdk diff --security-only --fail exits when security changes are present' , withDefaultFixture ( async ( fixture ) => {
779
931
const stackName = 'iam-test' ;
780
932
await expect ( fixture . cdk ( [ 'diff' , '--security-only' , '--fail' , fixture . fullStackName ( stackName ) ] ) ) . rejects . toThrow ( 'exited with error' ) ;
0 commit comments