Guest User

Untitled

a guest
May 15th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.80 KB | None | 0 0
  1. """
  2. Meta
  3. ====
  4. Revision          $Id: //splunk/current/new_test/tests/
  5.                       hunk/test_user_impersonation.py
  6. Last Changed at   $DateTime:
  7.  
  8. """
  9. import xml.etree.cElementTree as etree
  10. import os
  11. import subprocess
  12.  
  13. import pytest
  14. from helmut.exceptions.search import SearchFailure
  15. from helmut.connector.base import Connector
  16. from pytest_splunk_marker import SplunkTest, TestPlatform, TestPriority
  17. from backend.conftest import execute_vix_search
  18.  
  19. pytestmark = SplunkTest(ci_group="group6")
  20.  
  21. def call_rest_endpoint(restconn_new, method, endpoint, kwargs=None):
  22.     '''
  23.    Hit the given restendpoint and returns json of results
  24.    '''
  25.     resp, cont = restconn_new.make_request(method, endpoint, kwargs)
  26.     assert resp['status'] == '200' or resp['status'] == '201'
  27.     return cont
  28.  
  29. def call_rest_endpoint(restconn_new, method, endpoint, kwargs=None):
  30.     '''
  31.    Hit the given restendpoint and returns json of results
  32.    '''
  33.     resp, cont = restconn_new.make_request(method, endpoint, kwargs)
  34.     assert resp['status'] == '200' or resp['status'] == '201'
  35.     return cont
  36.  
  37. @SplunkTest(platform=TestPlatform.linux, priority=TestPriority.p1)
  38. @pytest.mark.usefixtures("add_license_hunk")
  39. class TestSplunkAccessControl(object):
  40.     '''
  41.    Test Splunk Access Control
  42.    '''
  43.  
  44.     def test_admin_role_user_search(self, nightlysplunk, hadoop,
  45.                                        access_combined_1m_vix,
  46.                                        hadoop_provider, cleanup_datanodes,
  47.                                        cleanup_hdfs, restconn_new):
  48.         '''
  49.        HunkGalaxy-6750:HUNK: Admin role user - Search
  50.        '''
  51.         try:
  52.             username = "power"
  53.             password = "power"
  54.             role = "admin"
  55.             kwargs = {'name': username,
  56.                         'password': password,
  57.                         'roles': role,
  58.                         'output_mode': 'json'}
  59.             json_dict = call_rest_endpoint(restconn_new, 'POST', '/services/authentication/users', kwargs)
  60.             nightlysplunk.create_logged_in_connector(
  61.                 contype=Connector.REST, username=username,
  62.                 password=password, app='system')
  63.             connector = nightlysplunk.connector(Connector.REST, username)
  64.             query = 'search index={0}|stats count'.format(access_combined_1m_vix.name)
  65.             job_id = "test_" + username
  66.             json_dict = execute_vix_search(self, nightlysplunk, connector, query, job_id)
  67.             assert int(json_dict['results'][0]['count']) == 1000000
  68.  
  69.             search_log = get_search_log_rest_call(connector, job_id)
  70.             doc = get_xml_object(hadoop, hadoop_provider, stanza, search_log=search_log, job_id=job_id)
  71.             assert username == check_job_owner(doc)
  72.         except:
  73.             pass
Add Comment
Please, Sign In to add comment