示例#1
0
 def test_credentials_invalid_handleowner(self):
     """Exception occurs when handle owner is not index:prefix/suffix."""
     with self.assertRaises(HandleSyntaxError):
         inst = PIDClientCredentials(handle_server_url=self.url,
                                     username=self.handle,
                                     password=self.randompassword,
                                     prefix=self.prefix,
                                     handleowner='300myhandleowner')
示例#2
0
 def test_credentials_invalid_handleowner(self):
     """Exception occurs when handle owner is not index:prefix/suffix."""
     with self.assertRaises(HandleSyntaxError):
         inst = PIDClientCredentials(self.url,
                                     self.handle,
                                     self.randompassword,
                                     'myprefix',
                                     '300myhandleowner')
示例#3
0
 def test_credentials_constructor4(self):
     """Test credentials instantiation. No exception occurs if server url does not exist. """
     inst = PIDClientCredentials('blablabla',
                                 self.user,
                                 self.randompassword,
                                 'myprefix',
                                 '300:myhandle/owner')
     self.assertIsInstance(inst, PIDClientCredentials)
示例#4
0
 def test_credentials_constructor4(self):
     """Test credentials instantiation. Prefix and handleowner can be passed. """
     inst = PIDClientCredentials(handle_server_url=self.url,
                                 username=self.user,
                                 password=self.randompassword,
                                 prefix=self.prefix,
                                 handleowner=self.owner)
     self.assertIsInstance(inst, PIDClientCredentials)
示例#5
0
    def test_config_from_init(self):
        """Test credentials instantiation from JSON file, with config."""
        inst = PIDClientCredentials(self.url,
                                    self.user,
                                    self.randompassword,
                                    foo='bar',
                                    bar='baz')

        self.assertEqual(inst.get_config()['foo'], 'bar',
            'Config not the same as in json file.')

        self.assertEqual(inst.get_config()['bar'], 'baz',
            'Config not the same as in json file.')
示例#6
0
    def __init__(self):
        # Load config parameters for ckanext-handle
        self.development = config.get("ckanext.handle.development")
        self.resource_field = config.get("ckanext.handle.resource_field")
        self.package_field = config.get("ckanext.handle.package_field")
        self.proxy = config.get("ckanext.handle.proxy")
        self.prefix = config.get("ckanext.handle.prefix")
        if not self.development:
            self.handle_server_url = config.get(
                "ckanext.handle.handle_server_url")
            self.private_key = config.get("ckanext.handle.private_key")
            self.certificate_only = config.get(
                "ckanext.handle.certificate_only")

            # Create credentials and client for handle interaction
            self.cred = PIDClientCredentials(
                handle_server_url=self.handle_server_url,
                private_key=self.private_key,
                certificate_only=self.certificate_only)
            self.client = EUDATHandleClient.instantiate_with_credentials(
                self.cred)
示例#7
0
 def test_credentials_invalid_username(self):
     """Exception occurs when user name is not index:prefix/suffix."""
     with self.assertRaises(HandleSyntaxError):
         inst = PIDClientCredentials(self.url,
                                     self.handle,
                                     self.randompassword)
示例#8
0
 def test_credentials_constructor3(self):
     """Test credentials instantiation. No exception occurs if server url does not exist. """
     inst = PIDClientCredentials('blablabla',
                                 self.user,
                                 self.randompassword)
     self.assertIsInstance(inst, PIDClientCredentials)
示例#9
0
 def test_credentials_constructor2(self):
     """Test credentials instantiation. No exception occurs if username does not exist. """
     inst = PIDClientCredentials(self.url,
                                 '100:not/exist',
                                 self.randompassword)
     self.assertIsInstance(inst, PIDClientCredentials)
示例#10
0
 def test_credentials_constructor1(self):
     """Test credentials instantiation. No exception occurs if password wrong. """
     inst = PIDClientCredentials(self.url,
                                 self.user,
                                 self.randompassword)
     self.assertIsInstance(inst, PIDClientCredentials)