Ejemplo n.º 1
0
    def testkeystonegetter(self, m):
        """ Test the obtention of appropriate value of the Keystone service endpoint.
        """
        expiredusers = ExpiredUsers()

        result = expiredusers.get_keystone_endpoint()

        expectedresult = "http://cloud.lab.fiware.org:4730/"

        self.assertEqual(expectedresult, result)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
    def testcheckTime1(self, m):
        """ test the difference between two dates in string are bigger than 14 days."""
        expiredusers = ExpiredUsers('any tenant id', 'any username', 'any password')

        olddate = "2015-05-01"

        result = expiredusers.check_time(olddate)

        expectedresult = True

        self.assertEqual(expectedresult, result)
Ejemplo n.º 4
0
    def testkeystonesetter(self, m):
        """ Test the setter method to fis the Keystone service endpoint
        """
        expiredusers = ExpiredUsers()

        expectedresult = "any url"

        expiredusers.set_keystone_endpoint(expectedresult)

        result = expiredusers.get_keystone_endpoint()

        self.assertEqual(expectedresult, result)
Ejemplo n.º 5
0
    def testcheckTime2(self, m):
        """ test the difference between two dates in string are bigger than 14 days."""
        expiredusers = ExpiredUsers('any tenant id', 'any username', 'any password')

        aux = datetime.today()
        olddate = aux.strftime("%Y-%m-%d")

        result = expiredusers.check_time(olddate)

        expectedresult = False

        self.assertEqual(expectedresult, result)
Ejemplo n.º 6
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.º 7
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.º 8
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)
Ejemplo n.º 9
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.º 10
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)
Ejemplo n.º 11
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.'
Ejemplo n.º 12
0
def given_a_wrong_tenant_username_and_password(context, tenantname, username,
                                               password):
    """
    Check that the operation to recover trial users with wrong data produce an exception.
    :param context: Context of the acceptance test execution.
    :param tenantname: Wrong tenant name.
    :param username: Wrong user name.
    :param password: Wrong password.
    :return:
    """
    context.expiredusers = ExpiredUsers(tenantname, username, password)
Ejemplo n.º 13
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.º 14
0
def before_scenario(context, scenario):
    """
    HOOK: To be executed before each Scenario:
        - Init test variables
    """

    __logger__.info("Starting execution of scenario")
    __logger__.info("##############################")
    __logger__.info("##############################")

    context.expiredusers = ExpiredUsers(TENANT_NAME, USERNAME, PASSWORD)
    context.expiredusers.finalList = []
    context.expiredusers.listUsers = []
    context.expiredusers.token = None