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()
def setUp(self): # Load nuauth nuconfig = NuauthConf() self.nuauth = Nuauth(nuconfig) # Create client self.client = createClientWithCerts()
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()
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))
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()
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()
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))
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()
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))
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()
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()
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()
def testNuauthValidCA(self): self.startNuauth() self.client = createClientWithCerts() self.assert_(connectClient(self.client)) self.client.stop() self.stopNuauth()
def createClientWithCerts(self, more_args=None): return createClientWithCerts(self.login, self.password, more_args=more_args)
def testInvalidLogin(self): user = USERDB[0] client = createClientWithCerts(user.login+"x", user.password) self.assert_(not connectClient(client)) client.stop()
def testInvalidPass(self): user = USERDB[1] client = createClientWithCerts(user.login, user.password+"x") self.assert_(not connectClient(client)) client.stop()