Ejemplo n.º 1
0
    def test_LoginPortal_allMethods(self):

        newToken1 = "myToken1"
        newToken2 = "myToken2"

        token1 = LoginPortal.login(Authentication_loginName,
                                   Authentication_loginPassword)
        token2 = LoginPortal.getToken()
        token3 = LoginPortal.getKeystoneToken()
        user = LoginPortal.getKeystoneUserWithToken(token1)
        iden = LoginPortal.identArgIdentifier()

        self.assertEqual(iden, "--ident=")

        self.assertNotEqual(token1, "")
        self.assertIsNot(token1, None)
        self.assertEqual(token1, token2)
        self.assertEqual(token1, token3)

        self.assertIsNot(user.userName, None)
        self.assertNotEqual(user.userName, "")
        self.assertIsNot(user.id, None)
        self.assertNotEqual(user.id, "")

        LoginPortal.setKeystoneToken(newToken1)
        self.assertEqual(newToken1, LoginPortal.getKeystoneToken())
def getSchemaName(token=""):
    if (token == ""):
        userToken = LoginPortal.getToken()
    else:
        userToken = token
    keystoneUserId = LoginPortal.getKeystoneUserWithToken(userToken).id
    usersUrl = Config.CasJobsRESTUri + "/users/" + keystoneUserId
    headers = {'X-Auth-Token': userToken, 'Content-Type': 'application/json'}
    getResponse = requests.get(usersUrl, headers=headers)
    jsonResponse = json.loads(getResponse.content.decode())
    return "wsid_" + str(jsonResponse["WebServicesId"])
def testLoginPortal(user,password):
    token= LoginPortal.login(user,password)
    print("token=",token)
    user= LoginPortal.getKeystoneUserWithToken(token)
    print("user=",user.id,user.userName)
    return token
#logging in and getting current token from different ways

token1 = LoginPortal.login(Authentication_loginName, Authentication_loginPassword);
token2 = LoginPortal.getToken()
token3 = LoginPortal.getKeystoneToken()
print("token1=" + token1)#
print("token2=" + token2)#
print("token3=" + token3)#


# In[ ]:

#getting curent user info

user = LoginPortal.getKeystoneUserWithToken(token1)
print("userName="******"id=" + user.id)#
iden = LoginPortal.identArgIdentifier()
print("ident="+iden)#


# In[ ]:

#reseting the current token to another value:

LoginPortal.setKeystoneToken("myToken2")
token6 = LoginPortal.getKeystoneToken()
print("token6=" + token6)