Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_init_connector fails with geventhttpclient>=2.2.1 #1279

Closed
mweinelt opened this issue Apr 21, 2024 · 3 comments · Fixed by #1299
Closed

test_init_connector fails with geventhttpclient>=2.2.1 #1279

mweinelt opened this issue Apr 21, 2024 · 3 comments · Fixed by #1299

Comments

@mweinelt
Copy link

The geventhttpclient.HTTPClient.request.get_base_url function has been removed in geventhttpclient/geventhttpclient@d673ea9.

This breaks TestSwiftConnector.test_init_connector.

dulwich> ____________________ TestSwiftConnector.test_init_connector ____________________
dulwich> [gw2] linux -- Python 3.11.9 /nix/store/lpi16513bai8kg2bd841745vzk72475x-python3-3.11.9/bin/python3.11
dulwich> 
dulwich> self = <dulwich.contrib.test_swift.TestSwiftConnector testMethod=test_init_connector>
dulwich> 
dulwich>     def test_init_connector(self):
dulwich>         self.assertEqual(self.conn.auth_ver, "1")
dulwich>         self.assertEqual(self.conn.auth_url, "http://127.0.0.1:8080/auth/v1.0")
dulwich>         self.assertEqual(self.conn.user, "test:tester")
dulwich>         self.assertEqual(self.conn.password, "testing")
dulwich>         self.assertEqual(self.conn.root, "fakerepo")
dulwich>         self.assertEqual(
dulwich>             self.conn.storage_url, "http://127.0.0.1:8080/v1.0/AUTH_fakeuser"
dulwich>         )
dulwich>         self.assertEqual(self.conn.token, "12" * 10)
dulwich>         self.assertEqual(self.conn.http_timeout, 1)
dulwich>         self.assertEqual(self.conn.http_pool_length, 1)
dulwich>         self.assertEqual(self.conn.concurrency, 1)
dulwich>         self.conf.set("swift", "auth_ver", "2")
dulwich>         self.conf.set("swift", "auth_url", "http://127.0.0.1:8080/auth/v2.0")
dulwich>         with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v2):
dulwich>             conn = swift.SwiftConnector("fakerepo", conf=self.conf)
dulwich>         self.assertEqual(conn.user, "tester")
dulwich>         self.assertEqual(conn.tenant, "test")
dulwich>         self.conf.set("swift", "auth_ver", "1")
dulwich>         self.conf.set("swift", "auth_url", "http://127.0.0.1:8080/auth/v1.0")
dulwich>         with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1_error):
dulwich> >           self.assertRaises(
dulwich>                 swift.SwiftException,
dulwich>                 lambda: swift.SwiftConnector("fakerepo", conf=self.conf),
dulwich>             )
dulwich> 
dulwich> dulwich/contrib/test_swift.py:361: 
dulwich> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
dulwich> dulwich/contrib/test_swift.py:363: in <lambda>
dulwich>     lambda: swift.SwiftConnector("fakerepo", conf=self.conf),
dulwich> dulwich/contrib/swift.py:226: in __init__
dulwich>     self.storage_url, self.token = self.swift_auth_v1()
dulwich> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
dulwich> 
dulwich>     def swift_auth_v1(self):
dulwich>         self.user = self.user.replace(";", ":")
dulwich>         auth_httpclient = HTTPClient.from_url(
dulwich>             self.auth_url,
dulwich>             connection_timeout=self.http_timeout,
dulwich>             network_timeout=self.http_timeout,
dulwich>         )
dulwich>         headers = {"X-Auth-User": self.user, "X-Auth-Key": self.password}
dulwich>         path = urlparse.urlparse(self.auth_url).path
dulwich>     
dulwich>         ret = auth_httpclient.request("GET", path, headers=headers)
dulwich>     
dulwich>         # Should do something with redirections (301 in my case)
dulwich>     
dulwich>         if ret.status_code < 200 or ret.status_code >= 300:
dulwich>             raise SwiftException(
dulwich>                 "AUTH v1.0 request failed on "
dulwich>                 + "{} with error code {} ({})".format(
dulwich> >                   str(auth_httpclient.get_base_url()) + path,
dulwich>                     ret.status_code,
dulwich>                     str(ret.items()),
dulwich>                 )
dulwich>             )
dulwich> E           AttributeError: 'HTTPClient' object has no attribute 'get_base_url'
dulwich> 
dulwich> dulwich/contrib/swift.py:261: AttributeError
@jelmer
Copy link
Owner

jelmer commented Apr 21, 2024

Thanks for the report. I don't personally have a swift setup or know much about it (which is why it's in contrib); happy to review patches though.

@surfaceflinger
Copy link

@jelmer I can provide you with creds to OVH object storage (which is swift) if you want and won't drain my debit card :)

@jelmer
Copy link
Owner

jelmer commented May 3, 2024

Thanks for the offer. I'd personally rather focus on core Dulwich, but would happily merge improvements to the swift support - either to the code, or to support running the swift tests in a GitHub action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants