{"action":"created","issue":{"url":"https://api.github.com/repos/fedora-infra/bodhi/issues/184","labels_url":"https://api.github.com/repos/fedora-infra/bodhi/issues/184/labels{/name}","comments_url":"https://api.github.com/repos/fedora-infra/bodhi/issues/184/comments","events_url":"https://api.github.com/repos/fedora-infra/bodhi/issues/184/events","html_url":"https://github.com/fedora-infra/bodhi/issues/184","id":101875400,"number":184,"title":"don't test auth during Bodhi2Client creation?","user":{"login":"kparal","id":755451,"avatar_url":"https://avatars.githubusercontent.com/u/755451?v=3","gravatar_id":"","url":"https://api.github.com/users/kparal","html_url":"https://github.com/kparal","followers_url":"https://api.github.com/users/kparal/followers","following_url":"https://api.github.com/users/kparal/following{/other_user}","gists_url":"https://api.github.com/users/kparal/gists{/gist_id}","starred_url":"https://api.github.com/users/kparal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kparal/subscriptions","organizations_url":"https://api.github.com/users/kparal/orgs","repos_url":"https://api.github.com/users/kparal/repos","events_url":"https://api.github.com/users/kparal/events{/privacy}","received_events_url":"https://api.github.com/users/kparal/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-19T12:01:18Z","updated_at":"2015-08-19T15:59:08Z","closed_at":"2015-08-19T15:59:08Z","body":"This returns immediately:\r\n```\r\nbodhi = Bodhi2Client(base_url='https://bodhi.stg.fedoraproject.org/')\r\n```\r\nbut this doesn't:\r\n```\r\nbodhi = Bodhi2Client(base_url='https://bodhi.stg.fedoraproject.org/', username='aaa', password='bbb')\r\n```\r\nIt checks credentials during object initialization and throws an error if it's invalid. That can take several seconds.\r\n\r\nThis doesn't seem to me as a good design decision. It makes life for library users harder - they have to design their APIs to use singletons for bodhi clients, instead of creating the client when needed, because it wastes a few seconds every time this happens (even when the client is not used at all in the end). It can complicate unit testing (automatic network connections). It prevents object creation at one place, and then overriding some of the attributes later at a different place.\r\n\r\nI've read the source code and it seems that every method that needs authentication makes sure we're logged in (by calling `self.csrf()`). That's a good approach, authentication on use. What is the reason to have authentication on creation as well?\r\n\r\nI'd like to be able to create and initialize objects first, without them doing anything unnecessary. Once everything is created and set up and I decide to *use* it (by calling some methods), then I'd like to receive an auth error if there is one. It would be nice to have some separate method for checking auth correctness (`self.check_auth()` or `self.login()`), if I decide to check auth before calling any other method. But it would be nice to have separate from object creation.\r\n\r\nThoughts?\r\n\r\npython-fedora-0.5.4-1.fc22.noarch"},"comment":{"url":"https://api.github.com/repos/fedora-infra/bodhi/issues/comments/132649987","html_url":"https://github.com/fedora-infra/bodhi/issues/184#issuecomment-132649987","issue_url":"https://api.github.com/repos/fedora-infra/bodhi/issues/184","id":132649987,"user":{"login":"lmacken","id":9980,"avatar_url":"https://avatars.githubusercontent.com/u/9980?v=3","gravatar_id":"","url":"https://api.github.com/users/lmacken","html_url":"https://github.com/lmacken","followers_url":"https://api.github.com/users/lmacken/followers","following_url":"https://api.github.com/users/lmacken/following{/other_user}","gists_url":"https://api.github.com/users/lmacken/gists{/gist_id}","starred_url":"https://api.github.com/users/lmacken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmacken/subscriptions","organizations_url":"https://api.github.com/users/lmacken/orgs","repos_url":"https://api.github.com/users/lmacken/repos","events_url":"https://api.github.com/users/lmacken/events{/privacy}","received_events_url":"https://api.github.com/users/lmacken/received_events","type":"User","site_admin":false},"created_at":"2015-08-19T15:59:08Z","updated_at":"2015-08-19T15:59:08Z","body":"This has been fixed."}}