Esempio n. 1
0
    def testadmintokenWithoutCredentials(self, m):
        """Test the obtention of admin token without credentials"""
        expiredUsers = ExpiredUsers()

        expectedmessage = 'Error, you need to define the credentials of the admin user. ' \
                          'Please, execute the setCredentials() method previously.'

        try:
            expiredUsers.get_admin_token()
        except ValueError as e:
            self.assertEqual(e.message, expectedmessage)
Esempio n. 2
0
    def testadmintoken(self, m):
        """testadmintoken check that we have an admin token"""
        response = {'access': {'token': {'id': '49ede5a9ce224631bc778cceedc0cca1'}}}

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

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

        expiredUsers.get_admin_token()

        resultToken = expiredUsers.getadmintoken()
        expectedToken = "49ede5a9ce224631bc778cceedc0cca1"

        self.assertEqual(expectedToken, resultToken)
Esempio n. 3
0
    def testwrongadmintoken(self, m):
        """testworngadmintoken check that we have a worg credential data"""
        response = {
            "error": {
                "message": "The request you have made requires authentication.",
                "code": 401,
                "title": "Unauthorized"
            }
        }

        m.post(requests_mock.ANY, json=response, status_code=401)

        expiredUsers = ExpiredUsers('wrong tenant', 'any username', 'any password')

        try:
            expiredUsers.get_admin_token()
        except Exception as e:

            assert e.message == 'The request you have made requires authentication.'