示例#1
0
    def test_authorize_anonymous(self):
        random_uuid = str(uuid.uuid4())
        new_password = self.faker.password()
        anonymous_user = User.create_anonymous(random_uuid, new_password)
        self.db.session.add(anonymous_user)
        self.db.session.commit()

        result = User.authorize_anonymous(random_uuid, new_password)

        assert result is not None and result == anonymous_user
示例#2
0
def get_anon_session(uuid):
    """
    
        If the uuid and password match, a  sessionId is
        returned as a string. This sessionId can to be passed
        along all the other requests that are annotated
        with @with_user in this file
        
    """
    password = request.form.get("password", None)

    if password is None:
        flask.abort(400)
    user = User.authorize_anonymous(uuid, password)
    if user is None:
        flask.abort(401)
    session = Session.for_user(user)
    db_session.add(session)
    db_session.commit()
    return str(session.id)
示例#3
0
def get_anon_session(uuid):
    """
    
        If the uuid and password match, a  sessionId is
        returned as a string. This sessionId can to be passed
        along all the other requests that are annotated
        with @with_user in this file
        
    """
    password = request.form.get("password", None)

    if password is None:
        flask.abort(400)
    user = User.authorize_anonymous(uuid, password)
    if user is None:
        flask.abort(401)
    session = Session.for_user(user)
    db_session.add(session)
    db_session.commit()
    return str(session.id)