def testPUTWithoutOriginFails(self): #This is run on prod with the prod dataset so mutating calls must fail and # tests must rely on checking for correct error # (IF test fails then it will return user creation not allowed because # we will never allow user creation on the master tenant) PUTdict = {"invalid": True} loginDICT = containerTestCommon.getLoginDICTForDefaultUser(self) jwtToken = loginDICT['jwtData']['JWTToken'] userName = "******" registerJSON = { "authProviderGUID": "InvalidGUID", "credentialJSON": { "username": userName, "password": "******" } } aa, res = callPutService(LOGIN, '/' + constants.masterTenantName + '/register', registerJSON, [401], loginDICT, headers=None, cookies=None, addOrigin=False) self.assertEqual(aa["message"], "Invalid Origin")
def test_URLParamsGoToServer(self): if containerTestCommon.runningViaKong: print("Skipping test_testNormalJWTHeader as this won't work via Kong - Kong can not read custom headers") return #https://api.metcarob.com/saas_user_management/v0/authed/api/admin/usersystem/users?query=code&pagesize=100&offset=0 loginDICT = containerTestCommon.getLoginDICTForDefaultUser(self) jwtToken = loginDICT['jwtData']['JWTToken'] headers = {} cookies = {constants.jwtCookieName: jwtToken} res, _ = callGetService( containerTestCommon.ADMIN, "/" + constants.masterTenantName + "/users", [200], None, headers, cookies ) self.assertNotEqual(len(res['result']), 0, msg="Should not have zero users") res2, _ = callGetService( containerTestCommon.ADMIN, "/" + constants.masterTenantName + "/users?query=codedfskhdsgew43tgrsadsasd&pagesize=100&offset=0&someotherparam=abs", [200], None, headers, cookies ) print(res2) self.assertEqual(len(res2['result']), 0, msg="Query paramater should have resulted in no results")
def test_testNormalJWTCookie(self): if containerTestCommon.runningViaKong: print("Skipping test_testNormalJWTHeader as this won't work via Kong - Kong can not read custom headers") return loginDICT = containerTestCommon.getLoginDICTForDefaultUser(self) jwtToken = loginDICT['jwtData']['JWTToken'] headers = {} cookies = {constants.jwtCookieName: jwtToken} tenantDICT, call_result = containerTestCommon.callGetService(containerTestCommon.ADMIN,"/" + constants.masterTenantName + containerTestCommon.securityTestAPIEndpoint, [200], None, headers, cookies)
def test_putCall(self): #With nginx not sure if put call will work. # if we get 503 we are getting an nginx error PUTdict = { "invalid": True } loginDICT = containerTestCommon.getLoginDICTForDefaultUser(self) jwtToken = loginDICT['jwtData']['JWTToken'] headers = {"Authorization": "Bearer " + jwtToken, "Origin": httpOrigin} cookies = {} callPutService(containerTestCommon.ADMINFRONTEND,"/" + constants.masterTenantName + "/tenants/usersystem", PUTdict, [405], loginDICT, headers, cookies)