Ejemplo n.º 1
0
    def testLogin(self):
        username = config.get("test_system", "username")
        password = config.get("test_system", "password")
        client = createClientWithCerts(username, password)
        self.assert_(connectClient(client))
        client.stop()

        client = createClientWithCerts(username, "xxx%sxxx" % password)
        self.assert_(not connectClient(client))
        client.stop()
Ejemplo n.º 2
0
    def testLogin(self):
        username = config.get("test_system", "username")
        password = config.get("test_system", "password")
        client = createClientWithCerts(username, password)
        self.assert_(connectClient(client))
        client.stop()

        client = createClientWithCerts(username, "xxx%sxxx" % password)
        self.assert_(not connectClient(client))
        client.stop()
Ejemplo n.º 3
0
    def setUp(self):
        # Load nuauth
        nuconfig = NuauthConf()
        self.nuauth = Nuauth(nuconfig)

        # Create client
        self.client = createClientWithCerts()
Ejemplo n.º 4
0
    def setUp(self):
        # Load nuauth
        nuconfig = NuauthConf()
        self.nuauth = Nuauth(nuconfig)

        # Create client
        self.client = createClientWithCerts()
Ejemplo n.º 5
0
 def testClientExpired(self):
     self.startNuauth()
     client1 = createClientWithCerts()
     self.assert_(connectClient(client1))
     tls_cert = abspath(config.get("test_cert", "user_expired_cert"))
     tls_key  = abspath(config.get("test_cert", "user_expired_key"))
     client2 = createClient(more_args=["-A", self.cacert,"-C",tls_cert,"-K",tls_key])
     self.assert_(not connectClient(client2))
     client1.stop()
     client2.stop()
     self.stopNuauth()
Ejemplo n.º 6
0
    def testLogin(self):
        # Client login
        client = createClientWithCerts()
        self.assert_(connectClient(client))

        # Check log output
        self.assert_(self.findLog("[nuauth] User %s connect on " % client.username))

        # Client logout
        client.stop()
        self.assert_(self.findLog("[nuauth] User %s disconnect on " % client.username))
Ejemplo n.º 7
0
 def testClientExpired(self):
     self.startNuauth()
     client1 = createClientWithCerts()
     self.assert_(connectClient(client1))
     tls_cert = abspath(config.get("test_cert", "user_expired_cert"))
     tls_key = abspath(config.get("test_cert", "user_expired_key"))
     client2 = createClient(
         more_args=["-A", self.cacert, "-C", tls_cert, "-K", tls_key])
     self.assert_(not connectClient(client2))
     client1.stop()
     client2.stop()
     self.stopNuauth()
Ejemplo n.º 8
0
 def testNuauthInvalidCA(self):
     cacert = abspath(config.get("test_cert", "invalid_cacert"))
     args = dict()
     args["nuauth_tls_cacert"] = "'%s'" % cacert
     # we must disable CRL for this one, else nuauth fails with an
     # error (CRL is not issued by CA)
     args["nuauth_tls_crl"] = None
     self.startNuauth(args)
     self.client = createClientWithCerts()
     self.assert_(not connectClient(self.client))
     self.client.stop()
     self.stopNuauth()
Ejemplo n.º 9
0
    def testLogin(self):
        # Client login
        client = createClientWithCerts()
        self.assert_(connectClient(client))

        # Check log output
        self.assert_(
            self.findLog("[nuauth] User %s connect on " % client.username))

        # Client logout
        client.stop()
        self.assert_(
            self.findLog("[nuauth] User %s disconnect on " % client.username))
Ejemplo n.º 10
0
 def testClientRevoked(self):
     args = dict()
     args["nuauth_tls_request_cert"] = "1"
     args["nuauth_tls_crl"] = '"%s"' % abspath(config.get("test_cert", "crl"))
     self.startNuauth(args)
     client1 = createClientWithCerts()
     self.assert_(connectClient(client1))
     tls_cert = abspath(config.get("test_cert", "user_revoked_cert"))
     tls_key  = abspath(config.get("test_cert", "user_revoked_key"))
     client2 = createClient(more_args=["-A", self.cacert,"-C",tls_cert,"-K",tls_key])
     self.assert_(not connectClient(client2))
     client1.stop()
     client2.stop()
     self.stopNuauth()
Ejemplo n.º 11
0
    def testLogin(self):
        # Client login
        client = createClientWithCerts()
        self.assert_(connectClient(client))

        # Check log output
        match = "SCRIPT UP COUNT=2 TEXT >>>%s %s<<<" \
            % (client.username, client.ip)
        self.assert_(self.checkScript(match))

        # Client logout
        client.stop()
        match = "SCRIPT DOWN COUNT=2 TEXT >>>%s %s<<<" \
            % (client.username, client.ip)
        self.assert_(self.checkScript(match))
Ejemplo n.º 12
0
    def testLogin(self):
        # Client login
        client = createClientWithCerts()
        self.assert_(connectClient(client))

        # Check log output
        match = "SCRIPT UP COUNT=2 TEXT >>>%s %s<<<" \
            % (client.username, client.ip)
        self.assert_(self.checkScript(match))

        # Client logout
        client.stop()
        match = "SCRIPT DOWN COUNT=2 TEXT >>>%s %s<<<" \
            % (client.username, client.ip)
        self.assert_(self.checkScript(match))
Ejemplo n.º 13
0
 def testClientRevoked(self):
     args = dict()
     args["nuauth_tls_request_cert"] = "1"
     args["nuauth_tls_crl"] = '"%s"' % abspath(
         config.get("test_cert", "crl"))
     self.startNuauth(args)
     client1 = createClientWithCerts()
     self.assert_(connectClient(client1))
     tls_cert = abspath(config.get("test_cert", "user_revoked_cert"))
     tls_key = abspath(config.get("test_cert", "user_revoked_key"))
     client2 = createClient(
         more_args=["-A", self.cacert, "-C", tls_cert, "-K", tls_key])
     self.assert_(not connectClient(client2))
     client1.stop()
     client2.stop()
     self.stopNuauth()
Ejemplo n.º 14
0
    def setUp(self):
        self.expiration = DURATION
        self.host = HOST

        # Setup session_expire library
        nuconfig = NuauthConf()
        nuconfig['nuauth_user_session_modify_module']='"session_expire"'
        nuconfig['nuauth_session_duration'] = str(self.expiration)

        # Install temporary user database
        self.userdb = PlaintextUserDB()
        self.userdb.addUser( PlaintextUser(USERNAME, PASSWORD, 42, 42) )
        self.userdb.install(nuconfig)
        self.acls = PlaintextAcl()

        # Start nuauth
        self.nuauth = Nuauth(nuconfig)

        # Create client
        self.client = createClientWithCerts()
Ejemplo n.º 15
0
    def setUp(self):
        self.expiration = DURATION
        self.host = HOST

        # Setup session_expire library
        nuconfig = NuauthConf()
        nuconfig['nuauth_user_session_modify_module'] = '"session_expire"'
        nuconfig['nuauth_session_duration'] = str(self.expiration)

        # Install temporary user database
        self.userdb = PlaintextUserDB()
        self.userdb.addUser(PlaintextUser(USERNAME, PASSWORD, 42, 42))
        self.userdb.install(nuconfig)
        self.acls = PlaintextAcl()

        # Start nuauth
        self.nuauth = Nuauth(nuconfig)

        # Create client
        self.client = createClientWithCerts()
Ejemplo n.º 16
0
 def testNuauthValidCA(self):
     self.startNuauth()
     self.client = createClientWithCerts()
     self.assert_(connectClient(self.client))
     self.client.stop()
     self.stopNuauth()
Ejemplo n.º 17
0
 def createClientWithCerts(self, more_args=None):
     return createClientWithCerts(self.login, self.password, more_args=more_args)
Ejemplo n.º 18
0
 def testInvalidLogin(self):
     user = USERDB[0]
     client = createClientWithCerts(user.login+"x", user.password)
     self.assert_(not connectClient(client))
     client.stop()
Ejemplo n.º 19
0
 def testInvalidPass(self):
     user = USERDB[1]
     client = createClientWithCerts(user.login, user.password+"x")
     self.assert_(not connectClient(client))
     client.stop()
Ejemplo n.º 20
0
 def createClientWithCerts(self, more_args=None):
     return createClientWithCerts(self.login,
                                  self.password,
                                  more_args=more_args)