Пример #1
0
    def update_user(self, username, first_name, last_name,
                    email, password):
        """Asks the client to update the user record"""

        req = UserRequest()
        req.username = username
        req.first_name = first_name
        req.last_name = last_name
        req.email = email
        req.password = password

        return self._make_request('user?username=%s' % username, data=req.new_user_json(), method='PUT')
Пример #2
0
    def test_user_request_produces_valid_json(self):

        req = UserRequest()
        req.username = "******"
        req.password = "******"
        req.remote_address = "127.0.0.1"

        self.assertEqual(
            req.to_json(),
            '{"username": "******", "password": "******", '
            '"validation-factors": {"validationFactors": [{"name": "remote_address", "value": "%s"}]}}'
            % (req.username, req.password, req.remote_address),
            "JSON does not match",
        )
Пример #3
0
    def create_user(self, username, first_name, last_name,
                    email, password):
        """Asks the client to create a user with the given information
            Params:
                username - login name for the user
                first_name - The name given to the user for use in an informal setting
                last_name - The name of the user's family
                email - Email address
                password - User's desired password
        """

        req = UserRequest()
        req.username = username
        req.first_name = first_name
        req.last_name = last_name
        req.email = email
        req.password = password

        return self._make_request('user', data=req.new_user_json())
Пример #4
0
    def create_user_session(self, user_name, password, remote_addr):
        """Asks the crowd provider for a user session token
            Params:
                user_name: Login name of the user
                password: Password of the user
                remote_addr: IP address the user is requesting from
            Returns:
                User object in JSON containing a 'token' from Crowd
                raises exception if invalid credentials
        """

        user = UserRequest()
        user.username = user_name
        user.password = password
        user.remote_address = remote_addr

        # Now we have enough information to make
        # a request to the Crowd API for a session
        return self._make_request('session', user.to_json())