示例#1
0
文件: test_use.py 项目: vartec/devpi
 def test_switch_to_temporary(self, makehub, mock_http_api):
     hub = makehub(['use'])
     mock_http_api.set("http://foo/+api",
                       200,
                       result=dict(pypisubmit="/post",
                                   simpleindex="/index/",
                                   index="root/some",
                                   bases="root/dev",
                                   login="******",
                                   authstatus=["noauth", ""]))
     current = Current()
     d = {
         "index": "http://l/some/index",
         "login": "******",
     }
     current.reconfigure(data=d)
     current.set_auth("user", "password")
     assert current.get_auth() == ("user", "password")
     temp = current.switch_to_temporary(hub, "http://foo")
     temp.set_auth("user1", "password1")
     assert temp.get_auth() == ("user1", "password1")
     # original is unaffected
     assert current.get_auth() == ("user", "password")
     assert temp._currentdict is not current._currentdict
     assert temp._currentdict['auth'] is not current._currentdict['auth']
示例#2
0
文件: test_use.py 项目: vartec/devpi
 def test_auth_multisite(self):
     current = Current()
     login1 = "http://site.com/+login"
     login2 = "http://site2.com/+login"
     current.login = login1
     current.set_auth("hello", "pass1")
     current.login = login2
     current.set_auth("hello", "pass2")
     assert current.get_auth(login1) == ("hello", "pass1")
     assert current.get_auth(login2) == ("hello", "pass2")
     current.login = login1
     current.del_auth()
     assert not current.get_auth(login1)
     assert current.get_auth(login2) == ("hello", "pass2")
     current.login = login2
     current.del_auth()
     assert not current.get_auth(login2)
示例#3
0
文件: test_use.py 项目: vartec/devpi
    def test_auth_handling(self, loghub):
        current = Current()
        d = {
            "index": "http://l/some/index",
            "login": "******",
        }
        current.reconfigure(data=d)
        assert current.rooturl
        current.set_auth("user", "password")
        assert current.get_auth() == ("user", "password")

        # ok response
        d["authstatus"] = ["ok", "user"]
        current._configure_from_server_api(d, URL(current.rooturl))
        assert current.get_auth() == ("user", "password")

        # invalidation response
        d["authstatus"] = ["nouser", "user"]
        current._configure_from_server_api(d, URL(current.rooturl))
        assert not current.get_auth()