예제 #1
0
 def test_if_protected(self, mock_get_cert):
     cert = certificate.create_from_file(
         demo_data.demo_entitlement_cert_path)
     cert.check_path = mock.Mock(return_value=True)
     mock_get_cert.return_value = cert
     result = mock_name_func('protected')
     self.assertEquals(result, 'foo')
예제 #2
0
    def test_not_authorized(self, mock_get_cert):
        cert = certificate.create_from_file(demo_data.demo_entitlement_cert_path)
        mock_get_cert.return_value = cert

        with self.assertRaises(exceptions.HTTPError) as assertion:
            mock_image_func('qux123')
        self.assertEquals(assertion.exception.status_code, httplib.NOT_FOUND)
예제 #3
0
 def test_auth_fails_if_no_path_matches_credentials(self, mock_get_cert):
     cert = certificate.create_from_file(
         demo_data.demo_entitlement_cert_path)
     mock_get_cert.return_value = cert
     with self.assertRaises(exceptions.HTTPError) as assertion:
         mock_repo_func('qux')
     self.assertEqual(assertion.exception.status_code, httplib.NOT_FOUND)
예제 #4
0
 def test_raises_not_found_if_id_invalid(self, mock_get_cert):
     cert = certificate.create_from_file(
         demo_data.demo_entitlement_cert_path)
     mock_get_cert.return_value = cert
     with self.assertRaises(exceptions.HTTPError) as assertion:
         mock_name_func('qux')
     self.assertEqual(assertion.exception.status_code, httplib.NOT_FOUND)
예제 #5
0
    def test_passes_if_auth_valid(self, mock_get_cert):
        cert = certificate.create_from_file(
            demo_data.demo_entitlement_cert_path)
        mock_get_cert.return_value = cert

        result = mock_name_func('v2/bar')
        self.assertEquals(result, 'foo')
예제 #6
0
파일: test_app_util.py 프로젝트: pulp/crane
    def test_not_authorized(self, mock_get_cert):
        cert = certificate.create_from_file(demo_data.demo_entitlement_cert_path)
        mock_get_cert.return_value = cert

        with self.assertRaises(exceptions.HTTPError) as assertion:
            mock_image_func('qux123')
        self.assertEquals(assertion.exception.status_code, httplib.NOT_FOUND)
예제 #7
0
 def uuid(self):
     """ Read consumer certificate and get consumer UUID from it. """
     if not self.cert_uuid:
         try:
             certificate = rhsm_certificate.create_from_file(self.cert_file)
             self.cert_uuid = certificate.subject["CN"]
         except Exception, e:
             raise SubscriptionManagerError("Unable to open certificate %s (%s):" % (self.cert_file, str(e)))
예제 #8
0
 def _create_cert(self):
     cert_file = self._get_file_from_args()
     try:
         return certificate.create_from_file(cert_file)
     except certificate.CertificateException as ce:
         raise InvalidCLIOptionError(
             _("Unable to read certificate file '{certificate}': {exception}"
               ).format(certificate=cert_file, exception=ce))
예제 #9
0
 def _create_cert(self):
     cert_file = self._get_file_from_args()
     try:
         return certificate.create_from_file(cert_file)
     except certificate.CertificateException as ce:
         raise InvalidCLIOptionError(
             _("Unable to read certificate file '%s': %s") %
             (cert_file, ce))
예제 #10
0
 def uuid(self):
     """ Read consumer certificate and get consumer UUID from it. """
     if not self.cert_uuid:
         try:
             certificate = rhsm_certificate.create_from_file(self.cert_file)
             self.cert_uuid = certificate.subject["CN"]
         except Exception, e:
             raise SubscriptionManagerError("Unable to open certificate %s (%s):" % (self.cert_file, str(e)))
 def _create_cert(self):
     cert_file = self._get_file_from_args()
     try:
         return certificate.create_from_file(cert_file)
     except certificate.CertificateException, ce:
         raise InvalidCLIOptionError(
                 _("Unable to read certificate file '%s': %s") % (cert_file,
                     ce))
 def list(self):
     if self._listing is not None:
         return self._listing
     listing = []
     for p, fn in Directory.list(self):
         if not fn.endswith('.pem') or fn.endswith(self.KEY):
             continue
         path = self.abspath(fn)
         listing.append(create_from_file(path))
     self._listing = listing
     return listing
예제 #13
0
 def list(self):
     if self._listing is not None:
         return self._listing
     listing = []
     for _p, fn in Directory.list(self):
         if not fn.endswith('.pem') or fn.endswith(self.KEY):
             continue
         path = self.abspath(fn)
         listing.append(create_from_file(path))
     self._listing = listing
     return listing
예제 #14
0
파일: test_app_util.py 프로젝트: pulp/crane
 def test_auth_fails_if_no_path_matches_credentials(self, mock_get_cert):
     cert = certificate.create_from_file(demo_data.demo_entitlement_cert_path)
     mock_get_cert.return_value = cert
     with self.assertRaises(exceptions.HTTPError) as assertion:
         mock_repo_func('qux')
     self.assertEqual(assertion.exception.status_code, httplib.NOT_FOUND)
예제 #15
0
파일: test_app_util.py 프로젝트: pulp/crane
 def test_if_protected(self, mock_get_cert):
     cert = certificate.create_from_file(demo_data.demo_entitlement_cert_path)
     cert.check_path = mock.Mock(return_value=True)
     mock_get_cert.return_value = cert
     result = mock_name_func('protected')
     self.assertEquals(result, 'foo')
예제 #16
0
 def _create_cert(self):
     return certificate.create_from_file(self._get_file_from_args())
예제 #17
0
 def test_non_existent_file(self):
     with self.assertRaises(CertificateException):
         create_from_file("/foo/non_existent_cert.pem")
예제 #18
0
 def _create_cert(self):
     return certificate.create_from_file(self._get_file_from_args())
예제 #19
0
파일: test_app_util.py 프로젝트: pulp/crane
 def test_passes_if_auth_valid(self, mock_get_cert):
     cert = certificate.create_from_file(demo_data.demo_entitlement_cert_path)
     mock_get_cert.return_value = cert
     result = mock_repo_func('baz')
     self.assertEquals(result, 'foo')
예제 #20
0
파일: test_app_util.py 프로젝트: pulp/crane
 def test_bypass_if_not_protected(self, mock_get_cert):
     cert = certificate.create_from_file(demo_data.demo_entitlement_cert_path)
     mock_get_cert.return_value = cert
     result = mock_repo_func('redhat/foo')
     self.assertEquals(result, 'foo')
예제 #21
0
 def read(cls):
     return create_from_file(cls.PATH)
예제 #22
0
파일: test_app_util.py 프로젝트: pulp/crane
 def test_raises_not_found_if_id_invalid(self, mock_get_cert):
     cert = certificate.create_from_file(demo_data.demo_entitlement_cert_path)
     mock_get_cert.return_value = cert
     with self.assertRaises(exceptions.HTTPError) as assertion:
         mock_name_func('qux')
     self.assertEqual(assertion.exception.status_code, httplib.NOT_FOUND)
예제 #23
0
 def test_bypass_if_not_protected(self, mock_get_cert):
     cert = certificate.create_from_file(
         demo_data.demo_entitlement_cert_path)
     mock_get_cert.return_value = cert
     result = mock_repo_func('redhat/foo')
     self.assertEquals(result, 'foo')