@@ -2571,17 +2571,18 @@ def test_connect_with_can_handle_expired_pw_flag(self):
2571
2571
2572
2572
2573
2573
@unittest .skipIf (tests .MYSQL_VERSION < (5 , 7 ),
2574
- "Authentication with ldap_simple not supported" )
2575
- #Skip if remote ldap server is not reachable.
2576
- @unittest .skipIf (not tests .is_host_reachable ("10.172.166.126" ),
2577
- "ldap server is not reachable" )
2578
- @unittest .skipIf (not tests .is_plugin_available ("authentication_ldap_sasl" ),
2579
- "Plugin authentication_ldap_sasl not available" )
2574
+ "Authentication with ldap_sasl not supported" )
2580
2575
class WL14110 (tests .MySQLConnectorTests ):
2581
2576
"""WL#14110: Add support for SCRAM-SHA-1
2582
2577
"""
2583
2578
def setUp (self ):
2584
2579
self .server = tests .MYSQL_SERVERS [0 ]
2580
+ if not "com" in self .server .license :
2581
+ self .skipTest ("Plugin not available in this version" )
2582
+ if not tests .is_host_reachable ("10.172.166.126" ):
2583
+ #Skip if remote ldap server is not reachable.
2584
+ self .skipTest ("Remote ldap server is not reachable" )
2585
+
2585
2586
self .server_cnf = self .server ._cnf
2586
2587
self .config = tests .get_mysql_config ()
2587
2588
self .config .pop ("unix_socket" , None )
@@ -2614,24 +2615,31 @@ def setUp(self):
2614
2615
self .server .wait_up ()
2615
2616
sleep (1 )
2616
2617
2617
- cnx = connection .MySQLConnection (** self .config )
2618
-
2619
- try :
2620
- cnx .cmd_query ("DROP USER '{}'@'{}'" .format (self .user , self .host ))
2621
- cnx .cmd_query ("DROP USER '{}'@'{}'" .format ("common" , self .host ))
2622
- except :
2623
- pass
2618
+ with connection .MySQLConnection (** self .config ) as cnx :
2619
+ cnx .cmd_query ("SHOW PLUGINS" )
2620
+ res = cnx .get_rows ()
2621
+ available = False
2622
+ for row in res [0 ]:
2623
+ if row [0 ].lower () == "authentication_ldap_sasl" :
2624
+ if row [1 ] == "ACTIVE" :
2625
+ available = True
2626
+ if not available :
2627
+ self .skipTest ("Plugin authentication_ldap_sasl not available" )
2624
2628
2625
- cnx .cmd_query ("CREATE USER '{}'@'{}' IDENTIFIED "
2626
- "WITH authentication_ldap_sasl"
2627
- "" .format (self .user , self .host ))
2629
+ try :
2630
+ cnx .cmd_query ("DROP USER '{}'@'{}'" .format (self .user , self .host ))
2631
+ cnx .cmd_query ("DROP USER '{}'@'{}'" .format ("common" , self .host ))
2632
+ except :
2633
+ pass
2628
2634
2629
- cnx .cmd_query ("CREATE USER '{}'@'{}'"
2630
- "" .format ("common" , self .host ))
2631
- cnx .cmd_query ("GRANT ALL ON *.* TO '{}'@'{}'"
2632
- "" .format ("common" , self .host ))
2635
+ cnx .cmd_query ("CREATE USER '{}'@'{}' IDENTIFIED "
2636
+ "WITH authentication_ldap_sasl"
2637
+ "" .format (self .user , self .host ))
2633
2638
2634
- cnx .close ()
2639
+ cnx .cmd_query ("CREATE USER '{}'@'{}'"
2640
+ "" .format ("common" , self .host ))
2641
+ cnx .cmd_query ("GRANT ALL ON *.* TO '{}'@'{}'"
2642
+ "" .format ("common" , self .host ))
2635
2643
2636
2644
def tearDown (self ):
2637
2645
return
@@ -2645,7 +2653,7 @@ def tearDown(self):
2645
2653
cnx .close ()
2646
2654
2647
2655
@tests .foreach_cnx ()
2648
- def test_authentication_ldap_sasl_client (self ):
2656
+ def test_authentication_ldap_sasl_client_with_SCRAM_SHA_1 (self ):
2649
2657
"""test_authentication_ldap_sasl_client_with_SCRAM-SHA-1"""
2650
2658
# Not running with c-ext if plugin libraries are not setup
2651
2659
if self .cnx .__class__ == CMySQLConnection and \
@@ -2700,16 +2708,17 @@ def test_authentication_ldap_sasl_client(self):
2700
2708
2701
2709
@unittest .skipIf (tests .MYSQL_VERSION < (5 , 7 ),
2702
2710
"Authentication with ldap_simple not supported" )
2703
- @unittest .skipIf (not tests .is_plugin_available ("authentication_ldap_simple" ),
2704
- "Plugin authentication_ldap_simple not available" )
2705
- #Skip if remote ldap server is not reachable.
2706
- @unittest .skipIf (not tests .is_host_reachable ("100.103.18.98" ),
2707
- "ldap server is not reachable" )
2708
2711
class WL13994 (tests .MySQLConnectorTests ):
2709
2712
"""WL#13994: Support clear text passwords
2710
2713
"""
2711
2714
def setUp (self ):
2712
2715
self .server = tests .MYSQL_SERVERS [0 ]
2716
+ if not "com" in self .server .license :
2717
+ self .skipTest ("Plugin not available in this version" )
2718
+ if not tests .is_host_reachable ("100.103.18.98" ):
2719
+ # Skip test, remote ldap server is not reachable.
2720
+ self .skipTest ("Remote ldap server is not reachable" )
2721
+
2713
2722
self .server_cnf = self .server ._cnf
2714
2723
self .config = tests .get_mysql_config ()
2715
2724
self .config .pop ("unix_socket" , None )
@@ -2746,17 +2755,26 @@ def setUp(self):
2746
2755
self .server .wait_up ()
2747
2756
sleep (1 )
2748
2757
2749
- cnx = connection .MySQLConnection (** self .config )
2750
-
2751
- identified_by = "CN=test1,CN=Users,DC=mysql,DC=local"
2752
-
2753
- cnx .cmd_query ("CREATE USER '{}'@'{}' IDENTIFIED "
2754
- "WITH authentication_ldap_simple AS"
2755
- "'{}'" .format (self .user , self .host , identified_by ))
2756
- cnx .cmd_query ("GRANT ALL ON *.* TO '{}'@'{}'"
2757
- "" .format (self .user , self .host ))
2758
- cnx .cmd_query ("FLUSH PRIVILEGES" )
2759
- cnx .close ()
2758
+ with connection .MySQLConnection (** self .config ) as cnx :
2759
+ cnx .cmd_query ("SHOW PLUGINS" )
2760
+ res = cnx .get_rows ()
2761
+ available = False
2762
+ for row in res [0 ]:
2763
+ if row [0 ].lower () == "authentication_ldap_simple" :
2764
+ if row [1 ] == "ACTIVE" :
2765
+ available = True
2766
+
2767
+ if not available :
2768
+ self .skipTest ("Plugin authentication_ldap_simple not available" )
2769
+
2770
+ identified_by = "CN=test1,CN=Users,DC=mysql,DC=local"
2771
+
2772
+ cnx .cmd_query ("CREATE USER '{}'@'{}' IDENTIFIED "
2773
+ "WITH authentication_ldap_simple AS"
2774
+ "'{}'" .format (self .user , self .host , identified_by ))
2775
+ cnx .cmd_query ("GRANT ALL ON *.* TO '{}'@'{}'"
2776
+ "" .format (self .user , self .host ))
2777
+ cnx .cmd_query ("FLUSH PRIVILEGES" )
2760
2778
2761
2779
def tearDown (self ):
2762
2780
cnx = connection .MySQLConnection (** self .config )
@@ -2862,20 +2880,19 @@ def test_clear_text_pass(self):
2862
2880
self .assertRaises (InterfaceError , self .cnx .__class__ , ** conn_args )
2863
2881
2864
2882
2865
- plugin_opts = (("authentication_ldap_sasl_auth_method_name" , "SCRAM-SHA-256" ),)
2866
- @unittest .skipIf (tests .MYSQL_VERSION < (8 , 2 , 22 ),
2867
- "Authentication with ldap_simple not supported" )
2868
- #Skip if remote ldap server is not reachable.
2869
- @unittest .skipIf (not tests .is_host_reachable ("100.103.19.5" ),
2870
- "ldap server is not reachable" )
2871
- @unittest .skipIf (not tests .is_plugin_available ("authentication_ldap_sasl" ,
2872
- plugin_opts ),
2873
- "Plugin authentication_ldap_simple not available" )
2883
+ @unittest .skipIf (tests .MYSQL_VERSION < (8 , 0 , 22 ),
2884
+ "Authentication with ldap_sasl not supported" )
2874
2885
class WL14263 (tests .MySQLConnectorTests ):
2875
2886
"""WL#14110: Add support for SCRAM-SHA-256
2876
2887
"""
2877
2888
def setUp (self ):
2878
2889
self .server = tests .MYSQL_SERVERS [0 ]
2890
+ if not "com" in self .server .license :
2891
+ self .skipTest ("Plugin not available in this version" )
2892
+ if not tests .is_host_reachable ("100.103.19.5" ):
2893
+ # Skip if remote ldap server is not reachable.
2894
+ self .skipTest ("Remote ldap server is not reachable" )
2895
+
2879
2896
self .server_cnf = self .server ._cnf
2880
2897
self .config = tests .get_mysql_config ()
2881
2898
self .config .pop ("unix_socket" , None )
@@ -2908,27 +2925,33 @@ def setUp(self):
2908
2925
self .server .wait_up ()
2909
2926
sleep (1 )
2910
2927
2911
- cnx = connection .MySQLConnection (** self .config )
2912
-
2913
- try :
2914
- cnx .cmd_query ("DROP USER '{}'@'{}'" .format (self .user , self .host ))
2915
- cnx .cmd_query ("DROP USER '{}'@'{}'" .format ("common" , self .host ))
2916
- except :
2917
- pass
2928
+ with connection .MySQLConnection (** self .config ) as cnx :
2929
+ cnx .cmd_query ("SHOW PLUGINS" )
2930
+ res = cnx .get_rows ()
2931
+ available = False
2932
+ for row in res [0 ]:
2933
+ if row [0 ].lower () == "authentication_ldap_sasl" :
2934
+ if row [1 ] == "ACTIVE" :
2935
+ available = True
2936
+ if not available :
2937
+ self .skipTest ("Plugin authentication_ldap_sasl not available" )
2918
2938
2919
- cnx .cmd_query ("CREATE USER '{}'@'{}' IDENTIFIED "
2920
- "WITH authentication_ldap_sasl"
2921
- "" .format (self .user , self .host ))
2939
+ try :
2940
+ cnx .cmd_query ("DROP USER '{}'@'{}'" .format (self .user , self .host ))
2941
+ cnx .cmd_query ("DROP USER '{}'@'{}'" .format ("common" , self .host ))
2942
+ except :
2943
+ pass
2922
2944
2923
- cnx .cmd_query ("CREATE USER '{}'@'{}'"
2924
- "" .format ("common" , self .host ))
2925
- cnx .cmd_query ("GRANT ALL ON *.* TO '{}'@'{}'"
2926
- "" .format ("common" , self .host ))
2945
+ cnx .cmd_query ("CREATE USER '{}'@'{}' IDENTIFIED "
2946
+ "WITH authentication_ldap_sasl"
2947
+ "" .format (self .user , self .host ))
2927
2948
2928
- cnx .close ()
2949
+ cnx .cmd_query ("CREATE USER '{}'@'{}'"
2950
+ "" .format ("common" , self .host ))
2951
+ cnx .cmd_query ("GRANT ALL ON *.* TO '{}'@'{}'"
2952
+ "" .format ("common" , self .host ))
2929
2953
2930
2954
def tearDown (self ):
2931
- return
2932
2955
cnx = connection .MySQLConnection (** self .config )
2933
2956
try :
2934
2957
cnx .cmd_query ("DROP USER '{}'@'{}'" .format (self .user , self .host ))
@@ -2939,7 +2962,7 @@ def tearDown(self):
2939
2962
cnx .close ()
2940
2963
2941
2964
@tests .foreach_cnx ()
2942
- def test_authentication_ldap_sasl_client (self ):
2965
+ def test_authentication_ldap_sasl_client_with_SCRAM_SHA_256 (self ):
2943
2966
"""test_authentication_ldap_sasl_client_with_SCRAM-SHA-256"""
2944
2967
# Not running with c-ext if plugin libraries are not setup
2945
2968
if self .cnx .__class__ == CMySQLConnection and \
@@ -3086,19 +3109,20 @@ def test_failover(self):
3086
3109
_ = connect (** cnx_config )
3087
3110
3088
3111
@unittest .skipIf (tests .MYSQL_VERSION < (5 , 7 ),
3089
- "Authentication with ldap_simple not supported" )
3090
- #Skip if remote ldap server is not reachable.
3091
- @unittest .skipIf (not tests .is_host_reachable ("100.103.18.98" ),
3092
- "ldap server is not reachable" )
3093
- @unittest .skipIf (not tests .is_plugin_available ("authentication_ldap_sasl" ),
3094
- "Plugin authentication_ldap_sasl not available" )
3095
- @unittest .skipIf (os .name == "nt" , "Skipping due to GRANT PROXY issue" )
3112
+ "Authentication with sasl GSSAPI not supported" )
3113
+ @unittest .skipIf (os .name == "nt" , "Not available on Windows" )
3096
3114
@unittest .skipIf (gssapi == None , "GSSAPI Module not installed" )
3097
3115
class WL14213 (tests .MySQLConnectorTests ):
3098
3116
"""WL#14213: Add support for Kerberos authentication.
3099
3117
"""
3100
3118
def setUp (self ):
3101
3119
self .server = tests .MYSQL_SERVERS [0 ]
3120
+ if not "com" in self .server .license :
3121
+ self .skipTest ("Plugin not available in this version" )
3122
+ if not tests .is_host_reachable ("100.103.18.98" ):
3123
+ # Skip if remote ldap server is not reachable.
3124
+ self .skipTest ("Remote ldap server is not reachable" )
3125
+
3102
3126
self .server_cnf = self .server ._cnf
3103
3127
self .config = tests .get_mysql_config ()
3104
3128
self .user = "test3"
@@ -3133,26 +3157,33 @@ def setUp(self):
3133
3157
self .server .wait_up ()
3134
3158
sleep (1 )
3135
3159
3136
- cnx = connection .MySQLConnection (** self .config )
3137
-
3138
- try :
3139
- cnx .cmd_query ("DROP USER '{}@{}'" .format (self .user , self .host ))
3140
- cnx .cmd_query ("DROP USER '{}'" .format ("mysql_engineering" ))
3141
- except :
3142
- pass
3160
+ with connection .MySQLConnection (** self .config ) as cnx :
3161
+ cnx .cmd_query ("SHOW PLUGINS" )
3162
+ res = cnx .get_rows ()
3163
+ available = False
3164
+ for row in res [0 ]:
3165
+ if row [0 ].lower () == "authentication_ldap_sasl" :
3166
+ if row [1 ] == "ACTIVE" :
3167
+ available = True
3168
+ if not available :
3169
+ self .skipTest ("Plugin authentication_ldap_sasl not available" )
3143
3170
3144
- cnx .cmd_query ("CREATE USER '{}@{}' IDENTIFIED "
3145
- "WITH authentication_ldap_sasl "
3146
- "BY \" #testgrp=mysql_engineering\" "
3147
- "" .format (self .user , self .host ))
3171
+ try :
3172
+ cnx .cmd_query ("DROP USER '{}@{}'" .format (self .user , self .host ))
3173
+ cnx .cmd_query ("DROP USER '{}'" .format ("mysql_engineering" ))
3174
+ except :
3175
+ pass
3148
3176
3149
- cnx .cmd_query ("CREATE USER '{}'" .format ("mysql_engineering" ))
3150
- cnx .cmd_query ("GRANT ALL ON myconnpy.* TO '{}'"
3151
- "" .format ("mysql_engineering" ))
3152
- cnx .cmd_query ("GRANT PROXY on '{}' TO '{}@{}'"
3153
- "" .format ("mysql_engineering" , self .user , self .host ))
3177
+ cnx .cmd_query ("CREATE USER '{}@{}' IDENTIFIED "
3178
+ "WITH authentication_ldap_sasl "
3179
+ "BY \" #testgrp=mysql_engineering\" "
3180
+ "" .format (self .user , self .host ))
3154
3181
3155
- cnx .close ()
3182
+ cnx .cmd_query ("CREATE USER '{}'" .format ("mysql_engineering" ))
3183
+ cnx .cmd_query ("GRANT ALL ON myconnpy.* TO '{}'"
3184
+ "" .format ("mysql_engineering" ))
3185
+ cnx .cmd_query ("GRANT PROXY on '{}' TO '{}@{}'"
3186
+ "" .format ("mysql_engineering" , self .user , self .host ))
3156
3187
3157
3188
def tearDown (self ):
3158
3189
return
0 commit comments