Esempio n. 1
0
    def test_getKey_nonexistent(self):
        nc = NetworkController()
        data = {"id": "a", "level": "b", "name": "c"}

        nc.truncateKeys("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addKey("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data)
        response = nc.getKey("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "b")
        self.assertEqual(response.error, consts.ERROR_NONEXISTENT_ENTRY)
Esempio n. 2
0
    def test_getKey_unauthorized(self):
        nc = NetworkController()
        data = {"id": "a", "level": "b", "name": "c"}

        nc.truncateKeys("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addKey("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data)
        response = nc.getKey("asdf", "a")
        self.assertEqual(response.error, consts.ERROR_UNAUTHORIZED_OPERATION)
Esempio n. 3
0
    def test_getKey_goodByUnhashedUak(self):
        nc = NetworkController()
        data = {"id": "a", "level": "b", "name": "c"}

        nc.truncateKeys("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addKey("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data)
        response = nc.getKey("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a")
        self.assertEqual(response.error, consts.NO_ERROR)
        self.assertEqual(response.payload["level"], "b")
        self.assertEqual(response.payload["name"], "c")
Esempio n. 4
0
    def test_removeKey_unauthorized(self):
        nc = NetworkController()

        nc.truncateKeys("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addKey("AS62ELRB5F0709LERPHZD06JWC0P8QSC", {
            "uak": "a",
            "level": "b",
            "name": "c"
        })
        response = nc.removeKey("DDPR0TG8EF760QR2J7IUF3UFIRXXL4E3", "a")
        self.assertEqual(response.error, consts.ERROR_UNAUTHORIZED_OPERATION)

        response = nc.removeKey("asd", "a")
        self.assertEqual(response.error, consts.ERROR_UNAUTHORIZED_OPERATION)
Esempio n. 5
0
    def test_removeKey_goodByUak(self):
        nc = NetworkController()

        nc.truncateKeys("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addKey("AS62ELRB5F0709LERPHZD06JWC0P8QSC", {
            "id": "a",
            "level": "b",
            "name": "c"
        })

        response = nc.removeKey("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a")

        self.assertEqual(response.error, consts.NO_ERROR)
        response = nc.getAllKeys("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        self.assertEqual(len(response.payload), 0)
Esempio n. 6
0
    def test_addKey_incomplete(self):
        nc = NetworkController()
        data = {"id": "a", "level": "b"}

        nc.truncateKeys("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        response = nc.addKey("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data)
        self.assertEqual(response.error,
                         consts.ERROR_FAILED_DATABASE_ADD_INCOMPLETE_DATA)