示例#1
0
def test_send_response_fail():
    with patch.object(utils, 'is_successful') as is_successful:
        is_successful.return_value = False
        with patch.object(utils, 'get_error_msg') as get_error_msg:
            get_error_msg.return_value = None
            with assert_raises(exceptions.KempTechApiException):
                utils.send_response('any_response')
示例#2
0
 def alsi_license(self, kemp_id, password):
     params = {
         "kempid": kemp_id,
         "password": password,
     }
     response = self._get('/alsilicense', parameters=params)
     return send_response(response)
示例#3
0
    def get_license_info(self):
        try:
            response = self._get('360/licenseinfo')
            return send_response(response)

        except KempTechApiException:
            raise CommandNotAvailableException(
                self, '/access360/licenseinfo')
示例#4
0
 def set_user_perms(self, user, perms=None):
     perms = [] if perms is None else perms
     perms = cast_to_list(perms)
     params = {
         'user': user,
         'perms': ",".join([perm for perm in perms]),
     }
     response = self._get('/usersetperms', params)
     return send_response(response)
示例#5
0
 def restore_backup(self, backup_type, file):
     # 1 LoadMaster Base Configuration
     # 2 Virtual Service Configuration
     # 3 GEO Configuration
     if backup_type not in [1, 2, 3]:
         backup_type = 2
     params = {"type": backup_type}
     response = self._post('/restore', file=file,
                           parameters=params)
     return send_response(response)
示例#6
0
    def add_local_user(self, user, password=None, radius=False):
        params = {
            'user': user,
            'radius': get_api_bool_string(radius),
        }
        if password is None:
            params['nopass'] = '******'
        else:
            params['password'] = password

        try:
            response = self._get('/useraddlocal', params)
        except KempTechApiException as e:
            if str(e) == "User already exists.":
                raise UserAlreadyExistsException(user, self.ip_address)
            else:
                raise
        return send_response(response)
示例#7
0
 def set_initial_password(self, password):
     params = {"passwd": password}
     response = self._get('/set_initial_passwd', parameters=params)
     return send_response(response)
示例#8
0
 def offline_license(self, license_file):
     response = self._post("/license", file=license_file)
     return send_response(response)
示例#9
0
 def list_addons(self):
     response = self._get('/listaddon')
     return send_response(response)
示例#10
0
 def upload_template(self, file):
     # Deprecated, use create_template
     response = self._post('/uploadtemplate', file)
     return send_response(response)
示例#11
0
 def delete_local_user(self, user):
     params = {'user': user}
     response = self._get('/userdellocal', params)
     return send_response(response)
示例#12
0
 def stats(self):
     response = self._get('/stats')
     return send_response(response)
示例#13
0
 def get_sdn_info(self):
     response = self._get('/sdninfo')
     return send_response(response)
示例#14
0
 def get_sdn_controller(self):
     response = self._get('/getsdncontroller')
     return send_response(response)
示例#15
0
 def delete_template(self, template_name):
     params = {'name': template_name}
     response = self._get('/deltemplate', parameters=params)
     return send_response(response)
示例#16
0
 def kill_asl_instance(self):
     response = self._get('/killaslinstance')
     return send_response(response)
def test_send_response_ok():
    with patch.object(utils, 'is_successful') as is_successful:
        is_successful.return_value = True
        with patch.object(utils, 'parse_to_dict') as parse_to_dict:
            utils.send_response('any_response')
            assert_true(parse_to_dict.called)
示例#18
0
 def new_user_cert(self, user):
     params = {'user': user}
     response = self._get('/usernewcert', params)
     return send_response(response)