44
44
AioSSOProvider ,
45
45
)
46
46
from aiobotocore .session import AioSession
47
-
48
- from .helpers import StubbedSession
47
+ from tests .boto_tests .helpers import StubbedSession
49
48
50
49
51
50
def random_chars (num_chars ):
52
51
return binascii .hexlify (os .urandom (int (num_chars / 2 ))).decode ('ascii' )
53
52
54
53
55
54
# From class TestCredentials(BaseEnvVar):
56
- @pytest .mark .moto
57
55
@pytest .mark .parametrize (
58
56
"access,secret" , [('foo\xe2 \x80 \x99 ' , 'bar\xe2 \x80 \x99 ' ), ('foo' , 'bar' )]
59
57
)
@@ -127,8 +125,6 @@ async def load():
127
125
return _f
128
126
129
127
130
- @pytest .mark .moto
131
- @pytest .mark .asyncio
132
128
async def test_assumerolefetcher_no_cache ():
133
129
response = {
134
130
'Credentials' : {
@@ -150,8 +146,6 @@ async def test_assumerolefetcher_no_cache():
150
146
assert response == expected_response
151
147
152
148
153
- @pytest .mark .moto
154
- @pytest .mark .asyncio
155
149
async def test_assumerolefetcher_cache_key_with_role_session_name ():
156
150
response = {
157
151
'Credentials' : {
@@ -180,8 +174,6 @@ async def test_assumerolefetcher_cache_key_with_role_session_name():
180
174
assert cache [cache_key ] == response
181
175
182
176
183
- @pytest .mark .moto
184
- @pytest .mark .asyncio
185
177
async def test_assumerolefetcher_cache_in_cache_but_expired ():
186
178
response = {
187
179
'Credentials' : {
@@ -215,8 +207,6 @@ async def test_assumerolefetcher_cache_in_cache_but_expired():
215
207
assert response == expected
216
208
217
209
218
- @pytest .mark .moto
219
- @pytest .mark .asyncio
220
210
async def test_assumerolefetcher_mfa ():
221
211
response = {
222
212
'Credentials' : {
@@ -248,8 +238,6 @@ async def test_assumerolefetcher_mfa():
248
238
assert call_kwargs ['TokenCode' ] == 'token-code'
249
239
250
240
251
- @pytest .mark .moto
252
- @pytest .mark .asyncio
253
241
async def test_recursive_assume_role (assume_role_setup ):
254
242
self = assume_role_setup
255
243
@@ -306,8 +294,6 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
306
294
return mock .Mock (return_value = _Client (with_response ))
307
295
308
296
309
- @pytest .mark .moto
310
- @pytest .mark .asyncio
311
297
async def test_webidentfetcher_no_cache ():
312
298
response = {
313
299
'Credentials' : {
@@ -329,8 +315,6 @@ async def test_webidentfetcher_no_cache():
329
315
assert response == expected_response
330
316
331
317
332
- @pytest .mark .moto
333
- @pytest .mark .asyncio
334
318
async def test_credresolver_load_credentials_single_provider (
335
319
credential_provider ,
336
320
):
@@ -347,8 +331,6 @@ async def test_credresolver_load_credentials_single_provider(
347
331
assert creds .token == 'c'
348
332
349
333
350
- @pytest .mark .moto
351
- @pytest .mark .asyncio
352
334
async def test_credresolver_no_providers (credential_provider ):
353
335
provider1 = credential_provider ('provider1' , 'CustomProvider1' , None )
354
336
resolver = credentials .AioCredentialResolver (providers = [provider1 ])
@@ -358,8 +340,6 @@ async def test_credresolver_no_providers(credential_provider):
358
340
359
341
360
342
# From class TestCanonicalNameSourceProvider(BaseEnvVar):
361
- @pytest .mark .moto
362
- @pytest .mark .asyncio
363
343
async def test_canonicalsourceprovider_source_creds (credential_provider ):
364
344
creds = credentials .AioCredentials ('a' , 'b' , 'c' )
365
345
provider1 = credential_provider ('provider1' , 'CustomProvider1' , creds )
@@ -372,8 +352,6 @@ async def test_canonicalsourceprovider_source_creds(credential_provider):
372
352
assert result is creds
373
353
374
354
375
- @pytest .mark .moto
376
- @pytest .mark .asyncio
377
355
async def test_canonicalsourceprovider_source_creds_case_insensitive (
378
356
credential_provider ,
379
357
):
@@ -418,8 +396,6 @@ def _f(config=None):
418
396
return _f
419
397
420
398
421
- @pytest .mark .moto
422
- @pytest .mark .asyncio
423
399
async def test_assumerolecredprovider_assume_role_no_cache (
424
400
credential_provider , assumerolecredprovider_config_loader
425
401
):
@@ -461,8 +437,6 @@ async def test_assumerolecredprovider_assume_role_no_cache(
461
437
462
438
463
439
# MFA
464
- @pytest .mark .moto
465
- @pytest .mark .asyncio
466
440
async def test_assumerolecredprovider_mfa (
467
441
credential_provider , assumerolecredprovider_config_loader
468
442
):
@@ -520,8 +494,6 @@ async def test_assumerolecredprovider_mfa(
520
494
assert call_kwargs ['TokenCode' ] == 'token-code'
521
495
522
496
523
- @pytest .mark .moto
524
- @pytest .mark .asyncio
525
497
async def test_assumerolecredprovider_mfa_cannot_refresh_credentials (
526
498
credential_provider , assumerolecredprovider_config_loader
527
499
):
@@ -577,8 +549,6 @@ async def test_assumerolecredprovider_mfa_cannot_refresh_credentials(
577
549
578
550
579
551
# From class TestAssumeRoleWithWebIdentityCredentialProvider
580
- @pytest .mark .moto
581
- @pytest .mark .asyncio
582
552
async def test_assumerolewebidentprovider_no_cache ():
583
553
future = datetime .now (tzlocal ()) + timedelta (hours = 24 )
584
554
@@ -630,8 +600,6 @@ def full_url(url):
630
600
631
601
632
602
# From class TestEnvVar(BaseEnvVar):
633
- @pytest .mark .moto
634
- @pytest .mark .asyncio
635
603
async def test_envvarprovider_env_var_present ():
636
604
environ = {
637
605
'AWS_ACCESS_KEY_ID' : 'foo' ,
@@ -646,17 +614,13 @@ async def test_envvarprovider_env_var_present():
646
614
assert creds .method == 'env'
647
615
648
616
649
- @pytest .mark .moto
650
- @pytest .mark .asyncio
651
617
async def test_envvarprovider_env_var_absent ():
652
618
environ = {}
653
619
provider = credentials .AioEnvProvider (environ )
654
620
creds = await provider .load ()
655
621
assert creds is None
656
622
657
623
658
- @pytest .mark .moto
659
- @pytest .mark .asyncio
660
624
async def test_envvarprovider_env_var_expiry ():
661
625
expiry_time = datetime .now (tzlocal ()) - timedelta (hours = 1 )
662
626
environ = {
@@ -691,8 +655,6 @@ def profile_config():
691
655
return parser
692
656
693
657
694
- @pytest .mark .moto
695
- @pytest .mark .asyncio
696
658
async def test_configprovider_file_exists (profile_config ):
697
659
provider = credentials .AioConfigProvider (
698
660
'cli.cfg' , 'default' , profile_config
@@ -705,8 +667,6 @@ async def test_configprovider_file_exists(profile_config):
705
667
assert creds .method == 'config-file'
706
668
707
669
708
- @pytest .mark .moto
709
- @pytest .mark .asyncio
710
670
async def test_configprovider_file_missing_profile (profile_config ):
711
671
provider = credentials .AioConfigProvider (
712
672
'cli.cfg' , 'NOT-default' , profile_config
@@ -716,8 +676,6 @@ async def test_configprovider_file_missing_profile(profile_config):
716
676
717
677
718
678
# From class TestSharedCredentialsProvider(BaseEnvVar):
719
- @pytest .mark .moto
720
- @pytest .mark .asyncio
721
679
async def test_sharedcredentials_file_exists ():
722
680
parser = mock .Mock ()
723
681
parser .return_value = {
@@ -740,8 +698,6 @@ async def test_sharedcredentials_file_exists():
740
698
assert creds .method == 'shared-credentials-file'
741
699
742
700
743
- @pytest .mark .moto
744
- @pytest .mark .asyncio
745
701
async def test_sharedcredentials_file_missing ():
746
702
parser = mock .Mock ()
747
703
parser .side_effect = botocore .exceptions .ConfigNotFound (path = 'foo' )
@@ -754,8 +710,6 @@ async def test_sharedcredentials_file_missing():
754
710
755
711
756
712
# From class TestBotoProvider(BaseEnvVar):
757
- @pytest .mark .moto
758
- @pytest .mark .asyncio
759
713
async def test_botoprovider_file_exists ():
760
714
parser = mock .Mock ()
761
715
parser .return_value = {
@@ -774,8 +728,6 @@ async def test_botoprovider_file_exists():
774
728
assert creds .method == 'boto-config'
775
729
776
730
777
- @pytest .mark .moto
778
- @pytest .mark .asyncio
779
731
async def test_botoprovider_file_missing ():
780
732
parser = mock .Mock ()
781
733
parser .side_effect = botocore .exceptions .ConfigNotFound (path = 'foo' )
@@ -786,8 +738,6 @@ async def test_botoprovider_file_missing():
786
738
787
739
788
740
# From class TestOriginalEC2Provider(BaseEnvVar):
789
- @pytest .mark .moto
790
- @pytest .mark .asyncio
791
741
async def test_originalec2provider_file_exists ():
792
742
envrion = {'AWS_CREDENTIAL_FILE' : 'foo.cfg' }
793
743
parser = mock .Mock ()
@@ -807,8 +757,6 @@ async def test_originalec2provider_file_exists():
807
757
assert creds .method == 'ec2-credentials-file'
808
758
809
759
810
- @pytest .mark .moto
811
- @pytest .mark .asyncio
812
760
async def test_originalec2provider_file_missing ():
813
761
provider = credentials .AioOriginalEC2Provider (environ = {})
814
762
creds = await provider .load ()
@@ -854,17 +802,13 @@ def fake_set_config_variable(self, logical_name, value):
854
802
return _f
855
803
856
804
857
- @pytest .mark .moto
858
- @pytest .mark .asyncio
859
805
async def test_createcredentialresolver (mock_session ):
860
806
session = mock_session ()
861
807
862
808
resolver = credentials .create_credential_resolver (session )
863
809
assert isinstance (resolver , credentials .AioCredentialResolver )
864
810
865
811
866
- @pytest .mark .moto
867
- @pytest .mark .asyncio
868
812
async def test_get_credentials (mock_session ):
869
813
session = mock_session ()
870
814
@@ -1098,8 +1042,6 @@ def assume_role_setup(base_assume_role_test_setup):
1098
1042
yield self
1099
1043
1100
1044
1101
- @pytest .mark .moto
1102
- @pytest .mark .asyncio
1103
1045
async def test_sso_credential_fetcher_can_fetch_credentials (
1104
1046
ssl_credential_fetcher_setup ,
1105
1047
):
@@ -1141,8 +1083,6 @@ async def test_sso_credential_fetcher_can_fetch_credentials(
1141
1083
self .assertEqual (self .cache [cache_key ], expected_cached_credentials )
1142
1084
1143
1085
1144
- @pytest .mark .moto
1145
- @pytest .mark .asyncio
1146
1086
async def test_sso_cred_fetcher_raises_helpful_message_on_unauthorized_exception (
1147
1087
ssl_credential_fetcher_setup ,
1148
1088
):
@@ -1246,8 +1186,6 @@ def _add_get_role_credentials_response(self):
1246
1186
)
1247
1187
1248
1188
1249
- @pytest .mark .moto
1250
- @pytest .mark .asyncio
1251
1189
async def test_load_sso_credentials_without_cache (sso_provider_setup ):
1252
1190
self = sso_provider_setup
1253
1191
_add_get_role_credentials_response (self )
@@ -1259,8 +1197,6 @@ async def test_load_sso_credentials_without_cache(sso_provider_setup):
1259
1197
self .assertEqual (credentials .token , 'baz' )
1260
1198
1261
1199
1262
- @pytest .mark .moto
1263
- @pytest .mark .asyncio
1264
1200
async def test_load_sso_credentials_with_cache (sso_provider_setup ):
1265
1201
self = sso_provider_setup
1266
1202
@@ -1280,8 +1216,6 @@ async def test_load_sso_credentials_with_cache(sso_provider_setup):
1280
1216
self .assertEqual (credentials .token , 'cached-st' )
1281
1217
1282
1218
1283
- @pytest .mark .moto
1284
- @pytest .mark .asyncio
1285
1219
async def test_load_sso_credentials_with_cache_expired (sso_provider_setup ):
1286
1220
self = sso_provider_setup
1287
1221
cached_creds = {
@@ -1304,8 +1238,6 @@ async def test_load_sso_credentials_with_cache_expired(sso_provider_setup):
1304
1238
self .assertEqual (credentials .token , 'baz' )
1305
1239
1306
1240
1307
- @pytest .mark .moto
1308
- @pytest .mark .asyncio
1309
1241
async def test_required_config_not_set (sso_provider_setup ):
1310
1242
self = sso_provider_setup
1311
1243
del self .config ['sso_start_url' ]
0 commit comments