@@ -17,6 +17,11 @@ def test_parse_auth_none_with_env():
1717 assert parse_auth (None ) == ('testkey' , '' )
1818
1919
20+ @mock .patch .dict (os .environ , {'SH_APIKEY' : 'testkey' , 'SHUB_JOBAUTH' : 'jwt' })
21+ def test_parse_auth_none_with_multiple_env ():
22+ assert parse_auth (None ) == ('testkey' , '' )
23+
24+
2025def test_parse_auth_tuple ():
2126 assert parse_auth (('test' , 'test' )) == ('test' , 'test' )
2227 assert parse_auth (('apikey' , '' )) == ('apikey' , '' )
@@ -52,6 +57,28 @@ def test_parse_auth_jwt_token():
5257 assert parse_auth (encoded_token ) == (test_job , test_token )
5358
5459
60+ def test_parse_auth_jwt_token_with_jwt_token_env ():
61+ dummy_test_job , dummy_test_token = '1/2/3' , 'some.dummy.jwt.token'
62+ raw_token = (dummy_test_job + ':' + dummy_test_token ).encode ('utf8' )
63+ dummy_encoded_token = encode (raw_token , 'hex_codec' ).decode ('ascii' )
64+
65+ test_job , test_token = '1/2/3' , 'some.jwt.token'
66+ raw_token = (test_job + ':' + test_token ).encode ('utf8' )
67+ encoded_token = encode (raw_token , 'hex_codec' ).decode ('ascii' )
68+
69+ with mock .patch .dict (os .environ , {'SHUB_JOBAUTH' : dummy_encoded_token }):
70+ assert parse_auth (encoded_token ) == (test_job , test_token )
71+
72+
73+ def test_parse_auth_none_with_jwt_token_env ():
74+ test_job , test_token = '1/2/3' , 'some.jwt.token'
75+ raw_token = (test_job + ':' + test_token ).encode ('utf8' )
76+ encoded_token = encode (raw_token , 'hex_codec' ).decode ('ascii' )
77+
78+ with mock .patch .dict (os .environ , {'SHUB_JOBAUTH' : encoded_token }):
79+ assert parse_auth (None ) == (test_job , test_token )
80+
81+
5582def test_parse_job_key ():
5683 job_key = parse_job_key ('123/10/11' )
5784 assert job_key .project_id == '123'
0 commit comments