本文整理汇总了Python中membase.api.rest_client.RestConnection.validateLogin方法的典型用法代码示例。如果您正苦于以下问题:Python RestConnection.validateLogin方法的具体用法?Python RestConnection.validateLogin怎么用?Python RestConnection.validateLogin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类membase.api.rest_client.RestConnection
的用法示例。
在下文中一共展示了RestConnection.validateLogin方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_checkWildCard
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import validateLogin [as 别名]
def test_checkWildCard(self):
#Create a REST connection
rest = RestConnection(self.master)
#Depending on the role specified as command line, pass parameters to the API
if (self.authRole == "fullAdmin"):
rest.ldapUserRestOperation(self.authState, self.fullAdmin, "*")
elif (self.authRole == 'roAdmin'):
rest.ldapUserRestOperation(self.authState, "*", self.ROAdmin)
elif (self.authRole == 'Both'):
rest.ldapUserRestOperation(self.authState, "*", "*")
#Get the response and then parse the JSON object and then check for multiple users
roAdmins, Admins = self._parseRestResponse(rest.ldapRestOperationGetResponse())
if (self.authRole == 'fullAdmin'):
self.assertTrue(self.validateReponse(Admins, self.fullAdmin), 'Response mismatch with expected fullAdmin - {0}'.format(self.validateReponse(Admins, self.fullAdmin)))
self.assertEqual("*", roAdmins[0], 'Validation for ROAdmins has failed: expected {0} - acutal {1}'.format("*", roAdmins))
elif (self.authRole == 'roAdmin'):
self.assertTrue(self.validateReponse(roAdmins, self.ROAdmin), 'Response mismatch with expected fullAdmin - {0}'.format(self.validateReponse(Admins, self.ROAdmin)))
self.assertEqual("*", Admins[0], 'Validation for ROAdmins has failed: expected {0} - acutal {1}'.format("*", Admins))
for user in self.fullAdmin:
status = rest.validateLogin(user[0], user[1], False)
self.assertTrue(status, 'User added as Admin has errors while login - user -- {0}'.format(user))
for user in self.ROAdmin:
status = rest.validateLogin(user[0], user[1], False)
self.assertTrue(status, 'User added as RoAdmin has errors while login - user -- {0}'.format(user))
示例2: test_fileRotate20MB
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import validateLogin [as 别名]
def test_fileRotate20MB(self):
auditIns = audit(host=self.master)
firstEventTime = self.getTimeStampForFile(auditIns)
tempEventCounter = 0
rest = RestConnection(self.master)
shell = RemoteMachineShellConnection(self.master)
filePath = auditIns.pathLogFile + auditIns.AUDITLOGFILENAME
number = int (shell.get_data_file_size(filePath))
hostname = shell.execute_command("hostname")
archiveFile = hostname[0][0] + '-' + firstEventTime + "-audit.log"
result = shell.file_exists(auditIns.pathLogFile, archiveFile)
tempTime = 0
starttime = time.time()
while ((number < 21089520) and (tempTime < 36000) and (result == False)):
for i in range(1, 10):
status, content = rest.validateLogin("Administrator", "password", True, getContent=True)
tempEventCounter += 1
number = int (shell.get_data_file_size(filePath))
currTime = time.time()
tempTime = int (currTime - starttime)
result = shell.file_exists(auditIns.pathLogFile, archiveFile)
self.sleep(30)
result = shell.file_exists(auditIns.pathLogFile, archiveFile)
shell.disconnect()
self.log.info ("--------Total Event Created ---- {0}".format(tempEventCounter))
self.assertTrue(result, "Archive Audit.log is not created on reaching 20MB threshhold")
示例3: test_rotateIntervalCluster
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import validateLogin [as 别名]
def test_rotateIntervalCluster(self):
intervalSec = self.input.param("intervalSec", None)
nodes_init = self.input.param("nodes_init", 2)
auditIns = audit(host=self.master)
auditIns.setAuditEnable('true')
originalInt = auditIns.getAuditRotateInterval()
auditIns.setAuditRotateInterval(intervalSec)
firstEventTime = []
try:
for i in range(len(self.servers[:nodes_init])):
auditTemp = audit(host=self.servers[i])
firstEventTime.append(self.getTimeStampForFile(auditTemp))
self.sleep(intervalSec + 20, 'Sleep for log roll over to happen')
for i in range(len(self.servers[:nodes_init])):
shell = RemoteMachineShellConnection(self.servers[i])
rest = RestConnection(self.servers[i])
status, content = rest.validateLogin(self.master.rest_username, self.master.rest_password, True, getContent=True)
self.sleep(120, "sleeping for log file creation")
try:
hostname = shell.execute_command("hostname")
self.log.info ("print firstEventTime {0}".format(firstEventTime[i]))
archiveFile = hostname[0][0] + '-' + firstEventTime[i] + "-audit.log"
self.log.info ("Archive File Name is {0}".format(archiveFile))
result = shell.file_exists(auditIns.pathLogFile, archiveFile)
self.assertTrue(result, "Archive Audit.log is not created on time interval")
self.log.info ("Validation of archive File created is True, Audit archive File is created {0}".format(archiveFile))
result = shell.file_exists(auditIns.pathLogFile, auditIns.AUDITLOGFILENAME)
self.assertTrue(result, "Audit.log is not created as per the roll over time specified")
finally:
shell.disconnect()
finally:
auditIns.setAuditRotateInterval(originalInt)
示例4: test_rotateInterval
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import validateLogin [as 别名]
def test_rotateInterval(self):
intervalSec = self.input.param("intervalSec", None)
auditIns = audit(host=self.master)
rest = RestConnection(self.master)
originalInt = auditIns.getAuditRotateInterval()
try:
firstEventTime = self.getTimeStampForFile(auditIns)
self.log.info ("first time evetn is {0}".format(firstEventTime))
auditIns.setAuditRotateInterval(intervalSec)
self.sleep(intervalSec + 20, 'Sleep for log roll over to happen')
status, content = rest.validateLogin(self.master.rest_username, self.master.rest_password, True, getContent=True)
self.sleep(120)
shell = RemoteMachineShellConnection(self.master)
try:
hostname = shell.execute_command("hostname")
archiveFile = hostname[0][0] + '-' + firstEventTime + "-audit.log"
self.log.info ("Archive File Name is {0}".format(archiveFile))
result = shell.file_exists(auditIns.pathLogFile, archiveFile)
self.assertTrue(result, "Archive Audit.log is not created on time interval")
self.log.info ("Validation of archive File created is True, Audit archive File is created {0}".format(archiveFile))
result = shell.file_exists(auditIns.pathLogFile, auditIns.AUDITLOGFILENAME)
self.assertTrue(result, "Audit.log is not created when memcached server is killed")
finally:
shell.disconnect()
finally:
auditIns.setAuditRotateInterval(originalInt)
示例5: test_ldapDeleteUser
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import validateLogin [as 别名]
def test_ldapDeleteUser(self):
#Get parameters that need to be removed from the list
removeUserAdmin = self.returnUserList(self.input.param("removeUserAdmin", ''))
removeUserROAdmin = self.returnUserList(self.input.param("removeUserROAdmin", ''))
rest = RestConnection(self.master)
self._setupLDAPAuth(rest, self.authRole, self.authState, self.fullAdmin, self.ROAdmin)
self._removeLdapUserRemote(removeUserAdmin)
self._removeLdapUserRemote(removeUserROAdmin)
for userAdmin, userROAdmin in zip(removeUserAdmin, removeUserROAdmin):
status = rest.validateLogin(userAdmin[0], userAdmin[1], False)
self.assertTrue(status)
status = rest.validateLogin(userROAdmin[0], userROAdmin[1], False)
self.assertTrue(status)
示例6: test_loginEvents
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import validateLogin [as 别名]
def test_loginEvents(self):
ops = self.input.param("ops", None)
role = self.input.param("role", None)
username = self.input.param('username', None)
password = self.input.param('password', None)
source = 'ns_server'
rest = RestConnection(self.master)
user = self.master.rest_username
roles = []
roles.append(role)
if (ops in ['loginRoAdmin', 'deleteuser', 'passwordChange']):
rest.create_ro_user(username, password)
if (ops in ['loginAdmin', 'loginRoAdmin']):
status, content = rest.validateLogin(username, password, True, getContent=True)
sessionID = (((status['set-cookie']).split("="))[1]).split(";")[0]
expectedResults = {'source':source, 'user':username, 'password':password, 'roles':roles, 'ip':self.ipAddress, "port":123456, 'sessionid':sessionID}
elif (ops in ['deleteuser']):
expectedResults = {"role":role, "real_userid:source":source, 'real_userid:user':user,
'ip':self.ipAddress, "port":123456, 'userid':username,'identity:source':'ro_admin','identity:user':'roAdmins'}
rest.delete_ro_user()
elif (ops in ['passwordChange']):
expectedResults = {'real_userid:source':source, 'real_userid:user':user,
'password':password, 'role':role, 'ip':self.ipAddress, "port":123456,
'userid':username,'identity:source':'ro_admin','identity:user':'roAdmins'}
rest.changePass_ro_user(username, password)
elif (ops in ['invalidlogin']):
status, content = rest.validateLogin(username, password, True, getContent=True)
expectedResults = {'real_userid':username, 'password':password,
'ip':self.ipAddress, "port":123456,'source': 'rejected','user':username}
#User must be pre-created in LDAP in advance
elif (ops in ['ldapLogin']):
rest = RestConnection(self.master)
self.set_user_role(rest,username)
status, content = rest.validateLogin(username, password, True, getContent=True)
sessionID = (((status['set-cookie']).split("="))[1]).split(";")[0]
expectedResults = {'source':'external', 'user':username, 'password':password, 'roles':roles, 'ip':self.ipAddress, "port":123456, 'sessionid':sessionID}
self.checkConfig(self.eventID, self.master, expectedResults)
示例7: test_cbServerOps
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import validateLogin [as 别名]
def test_cbServerOps(self):
ops = self.input.param("ops", None)
auditIns = audit(host=self.master)
#Capture timestamp from first event for filename
firstEventTime = self.getTimeStampForFile(auditIns)
shell = RemoteMachineShellConnection(self.master)
#Kill memcached to check for file roll over and new audit.log
if (ops == "kill"):
result = shell.kill_memcached()
self.sleep(10)
#Stop CB Server to check for file roll over and new audit.log
if (ops == 'shutdown'):
try:
result = shell.stop_couchbase()
self.sleep(120, 'Waiting for server to shutdown')
finally:
result = shell.start_couchbase()
#Check for audit.log and for roll over file
self.sleep(120, 'Waiting for server to start after shutdown')
rest = RestConnection(self.master)
#Create an Event for Bucket Creation
#expectedResults = self.createBucketAudit(self.master, "TestBucketKillShutdown")
status, content = rest.validateLogin("Administrator", "password", True, getContent=True)
self.sleep(30)
result = shell.file_exists(auditIns.pathLogFile, audit.AUDITLOGFILENAME)
self.assertTrue(result, "Audit.log is not created when memcached server is killed or stopped")
hostname = shell.execute_command("hostname")
archiveFile = hostname[0][0] + '-' + firstEventTime + "-audit.log"
self.log.info ("Archive File expected is {0}".format(auditIns.pathLogFile + archiveFile))
result = shell.file_exists(auditIns.pathLogFile, archiveFile)
self.assertTrue(result, "Archive Audit.log is not created when memcached server is killed or stopped")
#archiveFile = auditIns.currentLogFile + "/" + archiveFile
if (ops == 'shutdown'):
expectedResult = {"source":"internal", "user":"couchbase", "id":4097, "name":"shutting down audit daemon", "description":"The audit daemon is being shutdown"}
data = auditIns.returnEvent(4097, archiveFile)
flag = True
for items in data:
if (items == 'timestamp'):
tempFlag = auditIns.validateTimeStamp(data['timestamp'])
if (tempFlag is False):
flag = False
else:
if (isinstance(data[items], dict)):
for seclevel in data[items]:
tempValue = expectedResult[seclevel]
if data[items][seclevel] == tempValue:
self.log.info ('Match Found expected values - {0} -- actual value -- {1} - eventName - {2}'.format(tempValue, data[items][seclevel], seclevel))
else:
self.log.info ('Mis-Match Found expected values - {0} -- actual value -- {1} - eventName - {2}'.format(tempValue, data[items][seclevel], seclevel))
flag = False
else:
if (data[items] == expectedResult[items]):
self.log.info ('Match Found expected values - {0} -- actual value -- {1} - eventName - {2}'.format(expectedResult[items.encode('utf-8')], data[items.encode('utf-8')], items))
else:
self.log.info ('Mis - Match Found expected values - {0} -- actual value -- {1} - eventName - {2}'.format(expectedResult[items.encode('utf-8')], data[items.encode('utf-8')], items))
flag = False
self.assertTrue(flag, "Shutdown event is not printed")
expectedResults = {"auditd_enabled":auditIns.getAuditConfigElement('auditd_enabled'),
"descriptors_path":self.changePathWindows(auditIns.getAuditConfigElement('descriptors_path')),
"log_path":self.changePathWindows(auditIns.getAuditLogPath().strip()[:-2]),
'source':'internal', 'user':'couchbase',
"rotate_interval":auditIns.getAuditConfigElement('rotate_interval'),
"version":1, 'hostname':self.getHostName(self.master)}
self.checkConfig(self.AUDITCONFIGRELOAD, self.master, expectedResults)