Exemplo n.º 1
0
    def testDeleteEntries(self):
        testUser2 = uuid.uuid4()
        auth.saveAccessToken(self.sampleAuthMessage1, self.testUserUUID)
        auth.saveAccessToken(self.sampleAuthMessage3, testUser2)
        savedTokens = auth.getAccessToken(self.testUserUUID)
        self.assertEqual(len(savedTokens), 1)

        savedTokens2 = auth.getAccessToken(testUser2)
        self.assertEqual(len(savedTokens2), 1)

        auth.deleteAllTokens(self.testUserUUID)
        savedTokens = auth.getAccessToken(self.testUserUUID)
        self.assertEqual(len(savedTokens), 0)

        savedTokens2 = auth.getAccessToken(testUser2)
        self.assertEqual(len(savedTokens2), 1)
  def testDeleteEntries(self):
    testUser2 = uuid.uuid4()
    auth.saveAccessToken(self.sampleAuthMessage1, self.testUserUUID)
    auth.saveAccessToken(self.sampleAuthMessage3, testUser2)
    savedTokens = auth.getAccessToken(self.testUserUUID)
    self.assertEqual(len(savedTokens), 1)

    savedTokens2 = auth.getAccessToken(testUser2)
    self.assertEqual(len(savedTokens2), 1)

    auth.deleteAllTokens(self.testUserUUID)
    savedTokens = auth.getAccessToken(self.testUserUUID)
    self.assertEqual(len(savedTokens), 0)

    savedTokens2 = auth.getAccessToken(testUser2)
    self.assertEqual(len(savedTokens2), 1)
  def testAddNewUser(self):
    auth.saveAccessToken(self.sampleAuthMessage1, self.testUserUUID)
    savedTokens = auth.getAccessToken(self.testUserUUID)
    self.assertEqual(len(savedTokens), 1)
  
    # These are the values that are set in getAccessToken
    self.assertEqual(savedTokens[0]["our_uuid"], self.testUserUUID)
    self.assertEqual(savedTokens[0]["_id"], 99999999999999999)

    self.assertEqual(savedTokens[0]["access_token"], "Initial_token")
    self.assertEqual(savedTokens[0]["refresh_token"], "Initial_refresh_token")
Exemplo n.º 4
0
    def testAddNewUser(self):
        auth.saveAccessToken(self.sampleAuthMessage1, self.testUserUUID)
        savedTokens = auth.getAccessToken(self.testUserUUID)
        self.assertEqual(len(savedTokens), 1)

        # These are the values that are set in getAccessToken
        self.assertEqual(savedTokens[0]["our_uuid"], self.testUserUUID)
        self.assertEqual(savedTokens[0]["_id"], 99999999999999999)

        self.assertEqual(savedTokens[0]["access_token"], "Initial_token")
        self.assertEqual(savedTokens[0]["refresh_token"],
                         "Initial_refresh_token")
  def testUpdateExistingUser(self):
    auth.saveAccessToken(self.sampleAuthMessage1, self.testUserUUID)
    auth.saveAccessToken(self.sampleAuthMessage2, self.testUserUUID)
    savedTokens = auth.getAccessToken(self.testUserUUID)
    self.assertEqual(len(savedTokens), 1)

    # You can print out the current state for further reference
    print savedTokens[0]

    # These identify the user and should not be changed
    self.assertEqual(savedTokens[0]["our_uuid"], self.testUserUUID)
    self.assertEqual(savedTokens[0]["_id"], 99999999999999999)

    # These will be sent fresh with a second call to linkToMoves and should be changed
    self.assertEqual(savedTokens[0]["access_token"], "Updated_token")
    self.assertEqual(savedTokens[0]["refresh_token"], "Updated_refresh_token")
Exemplo n.º 6
0
    def testUpdateExistingUser(self):
        auth.saveAccessToken(self.sampleAuthMessage1, self.testUserUUID)
        auth.saveAccessToken(self.sampleAuthMessage2, self.testUserUUID)
        savedTokens = auth.getAccessToken(self.testUserUUID)
        self.assertEqual(len(savedTokens), 1)

        # You can print out the current state for further reference
        print savedTokens[0]

        # These identify the user and should not be changed
        self.assertEqual(savedTokens[0]["our_uuid"], self.testUserUUID)
        self.assertEqual(savedTokens[0]["_id"], 99999999999999999)

        # These will be sent fresh with a second call to linkToMoves and should be changed
        self.assertEqual(savedTokens[0]["access_token"], "Updated_token")
        self.assertEqual(savedTokens[0]["refresh_token"],
                         "Updated_refresh_token")
  def testDoubleRegisteredUser(self):
    auth.saveAccessToken(self.sampleAuthMessage1, self.testUserUUID)
    auth.saveAccessToken(self.sampleAuthMessage3, self.testUserUUID)
    savedTokens = auth.getAccessToken(self.testUserUUID)
    self.assertEqual(len(savedTokens), 2)

    firstDevice = None
    secondDevice = None

    for token in savedTokens:
      if token["_id"] == 99999999999999999:
        firstDevice = token
      else:
        secondDevice = token

    self.assertEqual(firstDevice["access_token"], "Initial_token")
    self.assertEqual(firstDevice["refresh_token"], "Initial_refresh_token")

    self.assertEqual(secondDevice["_id"], 11111111111111111)
    self.assertEqual(secondDevice["access_token"], "Updated_token")
    self.assertEqual(secondDevice["refresh_token"], "Updated_refresh_token")
Exemplo n.º 8
0
    def testDoubleRegisteredUser(self):
        auth.saveAccessToken(self.sampleAuthMessage1, self.testUserUUID)
        auth.saveAccessToken(self.sampleAuthMessage3, self.testUserUUID)
        savedTokens = auth.getAccessToken(self.testUserUUID)
        self.assertEqual(len(savedTokens), 2)

        firstDevice = None
        secondDevice = None

        for token in savedTokens:
            if token["_id"] == 99999999999999999:
                firstDevice = token
            else:
                secondDevice = token

        self.assertEqual(firstDevice["access_token"], "Initial_token")
        self.assertEqual(firstDevice["refresh_token"], "Initial_refresh_token")

        self.assertEqual(secondDevice["_id"], 11111111111111111)
        self.assertEqual(secondDevice["access_token"], "Updated_token")
        self.assertEqual(secondDevice["refresh_token"],
                         "Updated_refresh_token")