def test_token_successfully_obtained(self):
     time_now = isotime.add_utc_tz(datetime.datetime.now())
     registrar = InternalTriggerTypesRegistrar()
     self.assertTrue(registrar._auth_creds is not None)
     # TTL is at least 10 mins
     self.assertTrue((registrar._auth_creds.expiry - time_now).seconds > 10 * 60)
     delete_token(registrar._auth_creds.token)
Example #2
0
 def test_delete_token(self):
     token = access.create_token(USERNAME)
     access.delete_token(token.token)
     try:
         token = Token.get(token.token)
         self.assertTrue(False, 'Delete failed was expected to pass.')
     except TokenNotFoundError:
         self.assertTrue(True)
Example #3
0
 def test_delete_token(self):
     token = access.create_token(USERNAME)
     access.delete_token(token.token)
     try:
         token = Token.get(token.token)
         self.assertTrue(False, 'Delete failed was expected to pass.')
     except TokenNotFoundError:
         self.assertTrue(True)
Example #4
0
 def test_token_successfully_obtained(self):
     time_now = date_utils.get_datetime_utc_now()
     registrar = InternalTriggerTypesRegistrar()
     self.assertTrue(registrar._auth_creds is not None)
     # TTL is at least 10 mins
     self.assertTrue(
         (registrar._auth_creds.expiry - time_now).seconds > 10 * 60)
     delete_token(registrar._auth_creds.token)
Example #5
0
    def register_internal_trigger_types(self):
        LOG.debug('Registering internal trigger types...')

        for resource_name, trigger_definitions in INTERNAL_TRIGGER_TYPES.items():
            for trigger_definition in trigger_definitions:
                LOG.debug('Registering internal trigger: %s', trigger_definition['name'])
                if (trigger_definition['name'] == ACTION_SENSOR_TRIGGER['name'] and
                        not self._action_sensor_enabled):
                    continue
                self._register_trigger_type(trigger_definition=trigger_definition, attempt_no=0)

        delete_token(self._auth_creds.token)
Example #6
0
    def register_internal_trigger_types(self):
        LOG.debug('Registering internal trigger types...')

        for resource_name, trigger_definitions in INTERNAL_TRIGGER_TYPES.items():
            for trigger_definition in trigger_definitions:
                LOG.debug('Registering internal trigger: %s', trigger_definition['name'])
                if (trigger_definition['name'] == ACTION_SENSOR_TRIGGER['name'] and
                        not self._action_sensor_enabled):
                    continue
                self._register_trigger_type(trigger_definition=trigger_definition, attempt_no=0)

        delete_token(self._auth_creds.token)
Example #7
0
 def _delete_auth_token(self, auth_token):
     if auth_token:
         access.delete_token(auth_token.token)
Example #8
0
File: base.py Project: beryah/st2
 def _delete_auth_token(self, auth_token):
     if auth_token:
         access.delete_token(auth_token.token)
Example #9
0
 def test_delete_non_existent_token(self):
     token = uuid.uuid4().hex
     self.assertRaises(TokenNotFoundError, Token.get, token)
     access.delete_token(token)
Example #10
0
 def test_delete_non_existent_token(self):
     token = uuid.uuid4().hex
     self.assertRaises(TokenNotFoundError, Token.get, token)
     access.delete_token(token)
 def test_is_triger_type_exists_sad_case(self):
     registrar = InternalTriggerTypesRegistrar()
     is_exists = registrar._is_triggertype_exists('bar.foo')
     self.assertEqual(is_exists, False)
     delete_token(registrar._auth_creds.token)
 def test_get_trigger_type_url(self):
     registrar = InternalTriggerTypesRegistrar()
     url = registrar._get_trigger_type_url('foo.bar')
     self.assertEqual(url, 'http://localhost:9101/v1/triggertypes/foo.bar')
     delete_token(registrar._auth_creds.token)
Example #13
0
 def test_is_triger_type_exists_sad_case(self):
     registrar = InternalTriggerTypesRegistrar()
     is_exists = registrar._is_triggertype_exists('bar.foo')
     self.assertEqual(is_exists, False)
     delete_token(registrar._auth_creds.token)
Example #14
0
 def test_get_trigger_type_url(self):
     registrar = InternalTriggerTypesRegistrar()
     url = registrar._get_trigger_type_url('foo.bar')
     self.assertEqual(url, 'http://localhost:9101/v1/triggertypes/foo.bar')
     delete_token(registrar._auth_creds.token)