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