示例#1
0
 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)
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
 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
示例#5
0
    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)
示例#6
0
 def test_connection(self):
     client = iotkitclient.Client(config.api_url, proxies=config.proxies)
示例#7
0
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:
示例#8
0
 def test_getVersion(self):
     iot = iotkitclient.Client(hostname, proxies)
     version = iot.get_version()
     self.assertEqual(iot_version, version["build"])
示例#9
0
 def test_connect_bad_password2(self):
     iot = iotkitclient.Client(host=hostname, proxies=proxies)
     self.assertRaises(RuntimeError, iot.login, username, "xxx")
示例#10
0
 def test_connect_bad_password1(self):
     iot = iotkitclient.Client(host=hostname, proxies=proxies)
     self.assertRaises(ValueError, iot.login, username, None)
示例#11
0
 def test_connect_bad_username1(self):
     iot = iotkitclient.Client(host=hostname, proxies=proxies)
     self.assertRaises(RuntimeError, iot.login, "*****@*****.**", password)
示例#12
0
 def test_connect_default_host(self):
     iot = iotkitclient.Client(None, proxies)
示例#13
0
 def login(self):
     iot = iotkitclient.Client(host=hostname, proxies=proxies)
     iot.login(username, password)
     return iot
示例#14
0
 def test_auth_success(self):
     client = iotkitclient.Client(config.api_url, proxies=config.proxies)
     client.auth(config.username, config.password)
示例#15
0
 def setUpClass(cls):
     global iot
     iot = iotkitclient.Client(username, password, proxies)
示例#16
0
 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)
示例#17
0
 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)