Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Meta
- ====
- Revision $Id: //splunk/current/new_test/tests/
- hunk/test_user_impersonation.py
- Last Changed at $DateTime:
- """
- import xml.etree.cElementTree as etree
- import os
- import subprocess
- import pytest
- from helmut.exceptions.search import SearchFailure
- from helmut.connector.base import Connector
- from pytest_splunk_marker import SplunkTest, TestPlatform, TestPriority
- from backend.conftest import execute_vix_search
- pytestmark = SplunkTest(ci_group="group6")
- def call_rest_endpoint(restconn_new, method, endpoint, kwargs=None):
- '''
- Hit the given restendpoint and returns json of results
- '''
- resp, cont = restconn_new.make_request(method, endpoint, kwargs)
- assert resp['status'] == '200' or resp['status'] == '201'
- return cont
- def call_rest_endpoint(restconn_new, method, endpoint, kwargs=None):
- '''
- Hit the given restendpoint and returns json of results
- '''
- resp, cont = restconn_new.make_request(method, endpoint, kwargs)
- assert resp['status'] == '200' or resp['status'] == '201'
- return cont
- @SplunkTest(platform=TestPlatform.linux, priority=TestPriority.p1)
- @pytest.mark.usefixtures("add_license_hunk")
- class TestSplunkAccessControl(object):
- '''
- Test Splunk Access Control
- '''
- def test_admin_role_user_search(self, nightlysplunk, hadoop,
- access_combined_1m_vix,
- hadoop_provider, cleanup_datanodes,
- cleanup_hdfs, restconn_new):
- '''
- HunkGalaxy-6750:HUNK: Admin role user - Search
- '''
- try:
- username = "power"
- password = "power"
- role = "admin"
- kwargs = {'name': username,
- 'password': password,
- 'roles': role,
- 'output_mode': 'json'}
- json_dict = call_rest_endpoint(restconn_new, 'POST', '/services/authentication/users', kwargs)
- nightlysplunk.create_logged_in_connector(
- contype=Connector.REST, username=username,
- password=password, app='system')
- connector = nightlysplunk.connector(Connector.REST, username)
- query = 'search index={0}|stats count'.format(access_combined_1m_vix.name)
- job_id = "test_" + username
- json_dict = execute_vix_search(self, nightlysplunk, connector, query, job_id)
- assert int(json_dict['results'][0]['count']) == 1000000
- search_log = get_search_log_rest_call(connector, job_id)
- doc = get_xml_object(hadoop, hadoop_provider, stanza, search_log=search_log, job_id=job_id)
- assert username == check_job_owner(doc)
- except:
- pass
Add Comment
Please, Sign In to add comment