def test_make_plugin_produces_sensible_defaults(self): # The "audiences" parameter must be set explicitly self.assertRaises(ValueError, make_plugin) plugin = make_plugin("one two") self.assertEquals(plugin.audiences, ["one", "two"]) self.assertEquals(plugin.token_url, "/request_token") self.assertTrue(isinstance(plugin.verifier, vep.RemoteVerifier)) self.assertTrue(isinstance(plugin.token_manager, SignedTokenManager)) self.assertEquals(plugin.nonce_timeout, 60)
def test_make_plugin_can_explicitly_set_all_properties(self): plugin = make_plugin( audiences="example.com", token_url="/test_token_url", verifier="vep:DummyVerifier", token_manager="vep:LocalVerifier", nonce_timeout=42) self.assertEquals(plugin.audiences, ["example.com"]) self.assertEquals(plugin.token_url, "/test_token_url") self.assertTrue(isinstance(plugin.verifier, vep.DummyVerifier)) self.assertTrue(isinstance(plugin.token_manager, vep.LocalVerifier)) self.assertEquals(plugin.nonce_timeout, 42)
def test_make_plugin_can_explicitly_set_all_properties(self): plugin = make_plugin( audiences="example.com", token_url="/test_token_url", verifier="vep:DummyVerifier", token_manager="vep:LocalVerifier", nonce_timeout=42, ) self.assertEquals(plugin.audiences, ["example.com"]) self.assertEquals(plugin.token_url, "/test_token_url") self.assertTrue(isinstance(plugin.verifier, vep.DummyVerifier)) self.assertTrue(isinstance(plugin.token_manager, vep.LocalVerifier)) self.assertEquals(plugin.nonce_timeout, 42)
def test_make_plugin_treats_empty_audiences_string_as_none(self): plugin = make_plugin("") self.assertEquals(plugin.audiences, None) plugin = make_plugin(" ") self.assertEquals(plugin.audiences, [])
def test_make_plugin_loads_urlopen_from_dotted_name(self): plugin = make_plugin("one two", verifier="vep:LocalVerifier", verifier_urlopen="urllib2:urlopen") self.assertEquals(plugin.audiences, ["one", "two"]) self.assertTrue(isinstance(plugin.verifier, vep.LocalVerifier)) self.assertEquals(plugin.verifier.urlopen, urllib2.urlopen)