Ejemplo n.º 1
0
    def testlistTrialUsers(self, m):
        """testadmintoken check that we have an admin token"""
        response = {
            "role_assignments": [
                {"user": {"id": "0f4de1ea94d342e696f3f61320c15253"}, "links": {"assignment": "http://aurl.com/abc"}
                 },
                {"user": {"id": "24396976a1b84eafa5347c3f9818a66a"}, "links": {"assignment": "http://a.com"}
                 },
                {"user": {"id": "24cebaa9b665426cbeab579f1a3ac733"}, "links": {"assignment": "http://b.com"}
                 },
                {"user": {"id": "zippitelli"}, "links": {"assignment": "http://c.com"}
                 }
            ],
            "links": {"self": "http://d.com"}
        }

        m.get(requests_mock.ANY, json=response)

        expiredusers = ExpiredUsers('any tenant id', 'any username', 'any password')

        expiredusers.token = 'a token'
        expiredusers.get_list_trial_users()

        result = expiredusers.gerlisttrialusers()

        expectedresult = ['0f4de1ea94d342e696f3f61320c15253', '24396976a1b84eafa5347c3f9818a66a',
                          '24cebaa9b665426cbeab579f1a3ac733', 'zippitelli']

        self.assertEqual(expectedresult, result)
Ejemplo n.º 2
0
    def testCheckTimeExpiredwithNoAdminToken(self, m):
        """testadmintoken check that we have an admin token"""
        expiredusers = ExpiredUsers('any tenant id', 'any username', 'any password')

        # There was no users in the list
        expiredusers.token = ""
        expectedmessage = "Error, you need to have an admin token. Execute the get_admin_token() method previously."

        try:
            expiredusers.get_list_expired_users()
        except ValueError as e:
            self.assertEqual(e.message, expectedmessage)
Ejemplo n.º 3
0
    def testCheckTimeExpiredWithNoUsers(self, m):
        """testCheckTimeExpiredWithNoUsers check that we receive an error if we do not execute the
        get_list_trial_users() previously"""
        m.get(requests_mock.ANY, json=self.text_callback)

        expiredusers = ExpiredUsers('any tenant id', 'any username', 'any password')
        expiredusers.token = 'a token'

        result = expiredusers.get_list_expired_users()

        expectedresult = []

        self.assertEqual(expectedresult, result)
Ejemplo n.º 4
0
    def testCheckTimeExpiredwithNoListUsers(self, m):
        """testadmintoken check that we have an admin token"""

        expiredusers = ExpiredUsers('any tenant id', 'any username', 'any password')

        # There was no users in the list
        expiredusers.listUsers = []
        expiredusers.token = 'a token'

        result = expiredusers.get_list_expired_users()

        expectedresult = []

        self.assertEqual(expectedresult, result)
Ejemplo n.º 5
0
    def testCheckTimeExpired(self, m):
        """testadmintoken check that we have an admin token"""
        m.get(requests_mock.ANY, json=self.text_callback)

        expiredusers = ExpiredUsers('any tenant id', 'any username', 'any password')
        expiredusers.token = 'a token'
        expiredusers.listUsers = ['0f4de1ea94d342e696f3f61320c15253',
                                  '24396976a1b84eafa5347c3f9818a66a',
                                  'e3294fcf05984b3f934e189fa92c6990']

        result = expiredusers.get_list_expired_users()

        expectedresult = ['24396976a1b84eafa5347c3f9818a66a', 'e3294fcf05984b3f934e189fa92c6990']

        self.assertEqual(expectedresult, result)