Пример #1
0
    def test_login1(self):
        username = "******"
        password = "******"
        user.new_user(bokeh_app.servermodel_storage, username, password)
        sess = TestSession(client=app.test_client())
        #have not logged in yet, so userinfo should return http error
        self.assertRaises(Exception, lambda : sess.userinfo)

        #try logging in with wrong password, should be 403
        self.assertRaises(Exception, sess.login, 'testuser2', 'wrong password')

        #actually login
        sess.login('testuser2', 'fluffy')
        assert sess.userinfo['username'] == 'testuser2'
Пример #2
0
    def test_login1(self):
        username = "******"
        password = "******"
        user.new_user(bokeh_app.servermodel_storage, username, password)
        sess = Session(client=app.test_client())
        #have not logged in yet, so userinfo should return http error
        self.assertRaises(Exception, lambda: sess.userinfo)

        #try logging in with wrong password, should be 403
        self.assertRaises(Exception, sess.login, 'testuser2', 'wrong password')

        #actually login
        sess.login('testuser2', 'fluffy')
        assert sess.userinfo['username'] == 'testuser2'
Пример #3
0
    def test_login2(self):
        #create a server config, register a user
        config1 = tempfile.mkdtemp()
        server = Session(name="foo",
                         client=app.test_client(),
                         configdir=config1,
                         load_from_config=True)
        assert server.userapikey == "nokey"
        server.register("testuser", "fluffy")
        assert server.userapikey and server.userapikey != "nokey"

        config2 = tempfile.mkdtemp()
        server2 = Session(name="foo",
                          client=app.test_client(),
                          configdir=config2,
                          load_from_config=True)
        assert server2.userapikey == "nokey"
        server2.login("testuser", "fluffy")
        #make sure the userapikeys match
        assert server2.userapikey == server.userapikey
Пример #4
0
    def test_login2(self):
        #create a server config, register a user
        config1 = tempfile.mkdtemp()
        server = Session(name="foo",
                         client=app.test_client(),
                         configdir=config1,
                         load_from_config=True)
        assert server.userapikey == "nokey"
        server.register("testuser", "fluffy")
        assert server.userapikey and server.userapikey != "nokey"

        config2 = tempfile.mkdtemp()
        server2 = Session(name="foo",
                          client=app.test_client(),
                          configdir=config2,
                          load_from_config=True)
        assert server2.userapikey == "nokey"
        server2.login("testuser", "fluffy")
        #make sure the userapikeys match
        assert server2.userapikey == server.userapikey