def test_retrieve(self, mock_get_method):
     """ tests that the retrieve method works expected. """
     _setup_mock_response_for_retriever(
         mock_get_method, self._public_key_pem)
     retriever = HTTPSPublicKeyRetriever(self.base_url)
     self.assertEqual(
         retriever.retrieve('example/eg'),
         self._public_key_pem)
 def test_retrieve_fails_with_different_content_type(self, mock_get_method):
     """ tests that the retrieve method fails when the response is for a
         media type that is not supported.
     """
     headers = {'content-type': 'different/not-supported'}
     _setup_mock_response_for_retriever(
         mock_get_method, self._public_key_pem, headers)
     retriever = HTTPSPublicKeyRetriever(self.base_url)
     with self.assertRaises(ValueError):
         retriever.retrieve('example/eg')
 def test_retrieve_with_charset_in_content_type_h(self, mock_get_method):
     """ tests that the retrieve method works expected when there is
         a charset in the response content-type header.
     """
     headers = {'content-type': 'application/x-pem-file;charset=UTF-8'}
     _setup_mock_response_for_retriever(
         mock_get_method, self._public_key_pem, headers)
     retriever = HTTPSPublicKeyRetriever(self.base_url)
     self.assertEqual(
         retriever.retrieve('example/eg'),
         self._public_key_pem)
 def create_retriever(self, url):
     """ returns a public key retriever created using the given url. """
     return HTTPSPublicKeyRetriever(url)
 def test_https_public_key_retriever_supports_https_url(self):
     """ tests that HTTPSPublicKeyRetriever supports https://
         base urls.
     """
     retriever = HTTPSPublicKeyRetriever(self.base_url)
 def test_https_public_key_retriever_does_not_support_none_url(self):
     """ tests that HTTPSPublicKeyRetriever does not support None
         base urls.
     """
     with self.assertRaises(ValueError):
         retriever = HTTPSPublicKeyRetriever(None)
 def test_https_public_key_retriever_does_not_support_http_url(self):
     """ tests that HTTPSPublicKeyRetriever does not support http://
         base urls.
     """
     with self.assertRaises(ValueError):
         retriever = HTTPSPublicKeyRetriever('http://example.com')