@@ -635,14 +635,14 @@ def test_empty_dict_returns_aws_name(self):
635635 def test_match_by_name (self ):
636636 ps = _ps ("eks-developer" )
637637 result = RequestForAccessView ._get_permission_set_display_name (ps , display_names = {"eks-developer" : "EKS/kubectl access" })
638- assert result == "EKS/kubectl access"
638+ assert result == "EKS/kubectl access (eks-developer) "
639639
640640 def test_match_by_arn (self ):
641641 ps = _ps ("AdminAccess" , arn = "arn:aws:sso:::permissionSet/ssoins-abc/ps-admin" )
642642 result = RequestForAccessView ._get_permission_set_display_name (
643643 ps , display_names = {"arn:aws:sso:::permissionSet/ssoins-abc/ps-admin" : "Full Admin" }
644644 )
645- assert result == "Full Admin"
645+ assert result == "Full Admin (AdminAccess) "
646646
647647 def test_name_takes_priority_over_arn (self ):
648648 ps = _ps ("AdminAccess" , arn = "arn:aws:sso:::permissionSet/ssoins-abc/ps-admin" )
@@ -653,13 +653,18 @@ def test_name_takes_priority_over_arn(self):
653653 "arn:aws:sso:::permissionSet/ssoins-abc/ps-admin" : "By ARN" ,
654654 },
655655 )
656- assert result == "By Name"
656+ assert result == "By Name (AdminAccess) "
657657
658658 def test_no_match_falls_back_to_aws_name (self ):
659659 ps = _ps ("ReadOnly" )
660660 result = RequestForAccessView ._get_permission_set_display_name (ps , display_names = {"SomethingElse" : "Nope" })
661661 assert result == "ReadOnly"
662662
663+ def test_display_name_equal_to_aws_name_not_duplicated (self ):
664+ ps = _ps ("AdminAccess" )
665+ result = RequestForAccessView ._get_permission_set_display_name (ps , display_names = {"AdminAccess" : "AdminAccess" })
666+ assert result == "AdminAccess"
667+
663668 def test_long_name_truncated_to_75_chars (self ):
664669 ps = _ps ("AdminAccess" )
665670 long_label = "A" * 100
@@ -675,15 +680,15 @@ def test_options_use_display_names(self):
675680 display = {"AdminAccess" : "Full Admin" , "ReadOnly" : "Read-Only Access" }
676681 block = RequestForAccessView .build_select_permission_set_input_block (psets , display_names = display )
677682 texts = [_opt_text (opt ) for opt in block .element .options ] # type: ignore[union-attr]
678- assert "Full Admin" in texts
679- assert "Read-Only Access" in texts
683+ assert "Full Admin (AdminAccess) " in texts
684+ assert "Read-Only Access (ReadOnly) " in texts
680685
681686 def test_options_sorted_by_display_name (self ):
682687 psets = [_ps ("ZZZ-admin" ), _ps ("AAA-readonly" )]
683688 display = {"ZZZ-admin" : "Alpha" , "AAA-readonly" : "Beta" }
684689 block = RequestForAccessView .build_select_permission_set_input_block (psets , display_names = display )
685690 texts = [_opt_text (opt ) for opt in block .element .options ] # type: ignore[union-attr]
686- assert texts == ["Alpha" , "Beta" ]
691+ assert texts == ["Alpha (ZZZ-admin) " , "Beta (AAA-readonly) " ]
687692
688693 def test_options_sorted_by_aws_name_without_display_names (self ):
689694 psets = [_ps ("Zebra" ), _ps ("Alpha" )]
@@ -696,14 +701,14 @@ def test_value_is_arn_not_display_name(self):
696701 display = {"Admin" : "Friendly Label" }
697702 block = RequestForAccessView .build_select_permission_set_input_block (psets , display_names = display )
698703 assert block .element .options [0 ].value == "arn:aws:sso:::permissionSet/ssoins-abc/ps-123" # type: ignore[union-attr]
699- assert _opt_text (block .element .options [0 ]) == "Friendly Label" # type: ignore[union-attr]
704+ assert _opt_text (block .element .options [0 ]) == "Friendly Label (Admin) " # type: ignore[union-attr]
700705
701706 def test_mixed_matched_and_unmatched (self ):
702707 psets = [_ps ("Mapped" ), _ps ("Unmapped" )]
703708 display = {"Mapped" : "Custom Label" }
704709 block = RequestForAccessView .build_select_permission_set_input_block (psets , display_names = display )
705710 text_map = {_opt_text (opt ) for opt in block .element .options } # type: ignore[union-attr]
706- assert text_map == {"Custom Label" , "Unmapped" }
711+ assert text_map == {"Custom Label (Mapped) " , "Unmapped" }
707712
708713 def test_auto_approved_arns_none_uses_flat_options (self ):
709714 psets = [_ps ("Admin" ), _ps ("ReadOnly" )]
@@ -750,7 +755,7 @@ def test_option_groups_sorted_by_display_name(self):
750755 )
751756 groups = block .element .option_groups # type: ignore[union-attr]
752757 texts = [_opt_text (o ) for o in groups [0 ].options ]
753- assert texts == ["alpha" , "bravo" , "charlie" ]
758+ assert texts == ["alpha (ZZZ) " , "bravo (MMM) " , "charlie (AAA) " ]
754759
755760 def test_option_groups_use_display_names (self ):
756761 ps = _ps ("eks-developer" )
@@ -761,7 +766,7 @@ def test_option_groups_use_display_names(self):
761766 auto_approved_arns = {ps .arn },
762767 )
763768 groups = block .element .option_groups # type: ignore[union-attr]
764- assert _opt_text (groups [0 ].options [0 ]) == "EKS/kubectl access"
769+ assert _opt_text (groups [0 ].options [0 ]) == "EKS/kubectl access (eks-developer) "
765770
766771 def test_option_groups_value_is_arn (self ):
767772 ps = _ps ("Admin" , arn = "arn:aws:sso:::permissionSet/ssoins-abc/ps-123" )
@@ -793,8 +798,8 @@ def test_display_names_passed_through(self):
793798 # Find the permission set block options
794799 ps_block = next (b for b in view .blocks if getattr (b , "block_id" , None ) == RequestForAccessView .PERMISSION_SET_BLOCK_ID )
795800 texts = [_opt_text (opt ) for opt in ps_block .element .options ] # type: ignore[union-attr]
796- assert "Administrator" in texts
797- assert "Viewer" in texts
801+ assert "Administrator (Admin) " in texts
802+ assert "Viewer (ReadOnly) " in texts
798803
799804 def test_none_display_names_uses_aws_names (self ):
800805 blocks = self ._make_view_blocks ()
0 commit comments