示例#1
0
    def post(self, scope_name):
        """
        Mark the input DID as being followed by the given account.

        .. :quickref: Follow; Follow DID.

        HTTP Success:
            201 Created

        HTTP Error:
            401 Unauthorized
            404 Not Found
            500 Internal Error

        :param scope_name: data identifier (scope)/(name).
        """
        try:
            scope, name = parse_scope_name(scope_name, request.environ.get('vo'))
        except ValueError as error:
            return generate_http_error_flask(400, error)

        parameters = json_parameters()
        account = param_get(parameters, 'account')

        try:
            add_did_to_followed(scope=scope, name=name, account=account, vo=request.environ.get('vo'))
        except DataIdentifierNotFound as error:
            return generate_http_error_flask(404, error)
        except AccessDenied as error:
            return generate_http_error_flask(401, error)
示例#2
0
    def test_api_did(self):
        """ DID (API): Test external representation of DIDs """
        # add some dids
        add_did(self.scope_name, 'ext_parent', 'container', issuer='root', account=self.account_name, **self.vo)
        add_did(self.scope_name, 'ext_child', 'dataset', issuer='root', account=self.account_name, **self.vo)
        attachment = {'scope': self.scope_name, 'name': 'ext_parent',
                      'dids': [{'scope': self.scope_name, 'name': 'ext_child', 'type': 'DATASET'}]}
        attach_dids_to_dids([attachment], issuer='root', **self.vo)

        # test scope_list
        out = scope_list(self.scope_name, recursive=True, **self.vo)
        out = list(out)
        assert_not_equal(0, len(out))
        parent_found = False
        for did in out:
            assert_equal(did['scope'], self.scope_name)
            if did['parent'] is not None:
                parent_found = True
                assert_equal(did['parent']['scope'], self.scope_name)
        assert_true(parent_found)

        # test get_did
        add_did_to_followed(self.scope_name, 'ext_parent', self.account_name, **self.vo)
        out = get_users_following_did('ext_parent', self.scope_name, **self.vo)
        out = list(out)
        assert_not_equal(0, len(out))
        for user in out:
            assert_equal(user['user'], self.account_name)
示例#3
0
文件: did.py 项目: yiiyama/rucio
    def POST(self, scope, name):
        """
        Mark the input DID as being followed by the given account.

        HTTP Success:
            201 Created

        HTTP Error:
            401 Unauthorized
            404 Not Found
            500 Internal Error

        :param scope: The scope of the input DID.
        :param name: The name of the input DID.
        """
        try:
            json_data = loads(data())
        except ValueError:
            raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter list')

        try:
            add_did_to_followed(scope=scope, name=name, account=json_data['account'])
        except DataIdentifierNotFound as error:
            raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0])
        except AccessDenied as error:
            raise generate_http_error(401, 'AccessDenied', error.args[0])
        except DatabaseException as error:
            raise generate_http_error(500, 'DatabaseException', error.args[0])
        except RucioException as error:
            raise generate_http_error(500, error.__class__.__name__, error.args[0])
        except Exception as error:
            print(format_exc())
            raise InternalError(error)
示例#4
0
    def test_api_did(self):
        """ DID (API): Test external representation of DIDs """
        # add some dids
        ext_parent = did_name_generator('container')
        ext_child = did_name_generator('dataset')
        add_did(self.scope_name,
                ext_parent,
                'container',
                issuer='root',
                account=self.account_name,
                **self.vo)
        add_did(self.scope_name,
                ext_child,
                'dataset',
                issuer='root',
                account=self.account_name,
                **self.vo)
        attachment = {
            'scope':
            self.scope_name,
            'name':
            ext_parent,
            'dids': [{
                'scope': self.scope_name,
                'name': ext_child,
                'type': 'DATASET'
            }]
        }
        attach_dids_to_dids([attachment], issuer='root', **self.vo)

        # test scope_list
        out = scope_list(self.scope_name, recursive=True, **self.vo)
        out = list(out)
        assert 0 != len(out)
        parent_found = False
        for did in out:
            assert did['scope'] == self.scope_name
            if did['parent'] is not None:
                parent_found = True
                assert did['parent']['scope'] == self.scope_name
        assert parent_found

        # test get_did
        add_did_to_followed(self.scope_name, ext_parent, self.account_name,
                            **self.vo)
        out = get_users_following_did(ext_parent, self.scope_name, **self.vo)
        out = list(out)
        assert 0 != len(out)
        for user in out:
            assert user['user'] == self.account_name