MCPcopy Index your code
hub / github.com/docker/docker-py / ResolveAuthTest

Class ResolveAuthTest

tests/unit/auth_test.py:99–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97
98
99class ResolveAuthTest(unittest.TestCase):
100 index_config = {'auth': encode_auth({'username': 'indexuser'})}
101 private_config = {'auth': encode_auth({'username': 'privateuser'})}
102 legacy_config = {'auth': encode_auth({'username': 'legacyauth'})}
103
104 auth_config = auth.AuthConfig({
105 'auths': auth.parse_auth({
106 'https://index.docker.io/v1/': index_config,
107 'my.registry.net': private_config,
108 'http://legacy.registry.url/v1/': legacy_config,
109 })
110 })
111
112 def test_resolve_authconfig_hostname_only(self):
113 assert auth.resolve_authconfig(
114 self.auth_config, 'my.registry.net'
115 )['username'] == 'privateuser'
116
117 def test_resolve_authconfig_no_protocol(self):
118 assert auth.resolve_authconfig(
119 self.auth_config, 'my.registry.net/v1/'
120 )['username'] == 'privateuser'
121
122 def test_resolve_authconfig_no_path(self):
123 assert auth.resolve_authconfig(
124 self.auth_config, 'http://my.registry.net'
125 )['username'] == 'privateuser'
126
127 def test_resolve_authconfig_no_path_trailing_slash(self):
128 assert auth.resolve_authconfig(
129 self.auth_config, 'http://my.registry.net/'
130 )['username'] == 'privateuser'
131
132 def test_resolve_authconfig_no_path_wrong_secure_proto(self):
133 assert auth.resolve_authconfig(
134 self.auth_config, 'https://my.registry.net'
135 )['username'] == 'privateuser'
136
137 def test_resolve_authconfig_no_path_wrong_insecure_proto(self):
138 assert auth.resolve_authconfig(
139 self.auth_config, 'http://index.docker.io'
140 )['username'] == 'indexuser'
141
142 def test_resolve_authconfig_path_wrong_proto(self):
143 assert auth.resolve_authconfig(
144 self.auth_config, 'https://my.registry.net/v1/'
145 )['username'] == 'privateuser'
146
147 def test_resolve_authconfig_default_registry(self):
148 assert auth.resolve_authconfig(
149 self.auth_config
150 )['username'] == 'indexuser'
151
152 def test_resolve_authconfig_default_explicit_none(self):
153 assert auth.resolve_authconfig(
154 self.auth_config, None
155 )['username'] == 'indexuser'
156

Callers

nothing calls this directly

Calls 2

encode_authFunction · 0.85
parse_authMethod · 0.80

Tested by

no test coverage detected