def test_get_userinfo(self): iot2 = iotkitclient.Client(newusername, newpassword, proxies) user = iotkitclient.User(iot2) myid = str(uuid.uuid4()) # unique UUID info = {"attributes": {"myid": myid}} js = user.update_user(info) js = user.get_info() self.assertEqual(js["attributes"]["myid"], myid)
def setUpClass(cls): global iot, acct iot = iotkitclient.Client(host=hostname, proxies=proxies) iot.login(username, password) acct = iotkitclient.Account(iot) cls.deleteAll(newaccount) acct.create(newaccount) iot.reinit(username, password)
def test_change_user_password(self): newpassword2 = "WikiWikiW00" # change password user = iotkitclient.User(iot) user.change_password(newusername, newpassword, newpassword2) # check user can login w/ new password iot2 = iotkitclient.Client(newusername, newpassword2, proxies) # change password back user = iotkitclient.User(iot2) user.change_password(newusername, newpassword2, newpassword)
def setUpClass(cls): global iot, acct iot = iotkitclient.Client(host=hostname, proxies=proxies) iot.login(username, password) acct = iotkitclient.Account(iot) acct.get_account(account_name) while True: try: device = iotkitclient.Device(acct, deviceid) print "Deleting ", deviceid device.delete() except: break
def test_auth_fail(self): wrong_password = "******" client = iotkitclient.Client(config.api_url, proxies=config.proxies) try: client.auth(config.username, wrong_password) login_sucessful_with_wrong_password = True except iotkitclient.client.OICException as e: self.assertEqual(e.code, iotkitclient.client.OICException.NOT_AUTHORIZED) login_sucessful_with_wrong_password = False self.assertFalse(login_sucessful_with_wrong_password)
def test_connection(self): client = iotkitclient.Client(config.api_url, proxies=config.proxies)
import config import pdb reset_db = False # True if reset_db: print("Resetting DB") os.system("docker exec -it {} node /app/admin " "resetDB &> /dev/null".format(config.dashboard_container)) os.system("docker exec -it {} node /app/admin addUser {} {} {} " "&> /dev/null".format(config.dashboard_container, config.username, config.password, config.role)) client = iotkitclient.Client(api_root=config.api_url, proxies=config.proxies) client.auth(config.username, config.password) try: account = client.get_accounts()[0] except IndexError: account = client.create_account("debug_account") try: device = account.create_device("did", "dname", "gwid") device2 = account.create_device("did2", "dname2", "gwid") token = device.activate() resp = device.add_component("temp1", "temperature.v1.0") cid = resp["cid"] device_id = device.device_id with open("dtoken", "w") as f:
def test_getVersion(self): iot = iotkitclient.Client(hostname, proxies) version = iot.get_version() self.assertEqual(iot_version, version["build"])
def test_connect_bad_password2(self): iot = iotkitclient.Client(host=hostname, proxies=proxies) self.assertRaises(RuntimeError, iot.login, username, "xxx")
def test_connect_bad_password1(self): iot = iotkitclient.Client(host=hostname, proxies=proxies) self.assertRaises(ValueError, iot.login, username, None)
def test_connect_bad_username1(self): iot = iotkitclient.Client(host=hostname, proxies=proxies) self.assertRaises(RuntimeError, iot.login, "*****@*****.**", password)
def test_connect_default_host(self): iot = iotkitclient.Client(None, proxies)
def login(self): iot = iotkitclient.Client(host=hostname, proxies=proxies) iot.login(username, password) return iot
def test_auth_success(self): client = iotkitclient.Client(config.api_url, proxies=config.proxies) client.auth(config.username, config.password)
def setUpClass(cls): global iot iot = iotkitclient.Client(username, password, proxies)
def test_update_user2(self): iot2 = iotkitclient.Client(newusername, newpassword, proxies) user = iotkitclient.User(iot2) info = "" # empty info self.assertRaises(ValueError, user.update_user, info)
def test_update_user1(self): iot2 = iotkitclient.Client(newusername, newpassword, proxies) user = iotkitclient.User(iot2) myid = str(uuid.uuid4()) # unique UUID info = {"attributes": {"myid": myid}} js = user.update_user(info)