def test_authenticate_postdata_204(self): self.setup_mock() self.uuid4_m() self.mocker.result("focaccia") self.mocker.replay() url = self.get_url("blur") auth = DigestAuthenticator("quesadilla", "king") def check(response): self.assertTrue( response.startswith( 'Digest username="******", realm="p", nonce="q", uri="%s"' % url)) self.assertIn('qop="auth", nc="00000001", cnonce="focaccia"', response) self.add_auth("blur", "HURL", "", "Digest realm=p, nonce=q, qop=auth", check, expect_content="bbq", status=204) d = get_page_auth(url, auth, method="HURL", postdata="bbq") d.addCallback(self.assertEquals, "") return d
def test_authenticate_postdata_201(self): self.setup_mock() self.uuid4_m() self.mocker.result("ciabatta") self.mocker.replay() url = self.get_url("blam") auth = DigestAuthenticator("pizza", "principessa") def check(response): self.assertTrue( response.startswith( 'Digest username="******", realm="a", nonce="b", uri="%s"' % url)) self.assertIn('qop="auth", nc="00000001", cnonce="ciabatta"', response) self.add_auth("blam", "FLING", "tomato", "Digest realm=a, nonce=b, qop=auth", check, expect_content="oven", status=201) d = get_page_auth(url, auth, method="FLING", postdata="oven") d.addCallback(self.assertEquals, "tomato") return d
def test_authenticate(self): self.setup_mock() self.uuid4_m() self.mocker.result("baguette") self.mocker.replay() url = self.get_url("blip") auth = DigestAuthenticator("sandwich", "earl") def check(response): self.assertTrue( response.startswith( 'Digest username="******", realm="x", nonce="y", uri="%s"' % url)) self.assertIn('qop="auth", nc="00000001", cnonce="baguette"', response) self.add_auth("blip", "PROD", "ham", "Digest realm=x, nonce=y, qop=auth", check) d = get_page_auth(url, auth, method="PROD") d.addCallback(self.assertEquals, "ham") return d
def setUp(self): super(DigestAuthenticatorTest, self).setUp() self.uuid4_m = self.mocker.replace("uuid.uuid4") self.auth = DigestAuthenticator("jiminy", "cricket")
def __init__(self, config): fallback_url = "http://%(orchestra-server)s/webdav" % config self._base_url = config.get("storage-url", fallback_url) self._auth = DigestAuthenticator( config.get("storage-user", config["orchestra-user"]), config.get("storage-pass", config["orchestra-pass"]))