Beispiel #1
0
 def setUp(self):
     """Create test setup."""
     write_server_config(DEFAULT_CONFIG)
     # Temporarily disable stderr for these tests, CLI errors clutter up
     # nosetests command.
     self.orig_stderr = sys.stderr
     sys.stderr = HushUpStderr()
Beispiel #2
0
 def setUp(self):
     """Create test setup."""
     write_server_config(DEFAULT_CONFIG)
     # Temporarily disable stderr for these tests, CLI errors clutter up
     # nosetests command.
     self.orig_stderr = sys.stderr
     self.test_tar_filename = 'test_%d.tar.gz' % time.time()
     sys.stderr = HushUpStderr()
Beispiel #3
0
 def setUp(self):
     """Create test setup."""
     write_server_config(DEFAULT_CONFIG)
     # Temporarily disable stderr for these tests, CLI errors clutter up
     # nosetests command.
     self.orig_stderr = sys.stderr
     sys.stderr = HushUpStderr()
     self.login_url = get_server_location() + LOGIN_URI
     self.success_json = {'token': 'a_token'}
Beispiel #4
0
 def setUp(self):
     """Create test setup."""
     # Temporarily disable stderr for these tests, CLI errors clutter up
     # nosetests command.
     self.orig_stderr = sys.stderr
     sys.stderr = HushUpStderr()
     if os.path.isfile(TMP_KEY):
         os.remove(TMP_KEY)
     with open(TMP_KEY, 'w') as test_sshkey:
         test_sshkey.write('fake ssh keyfile.')
Beispiel #5
0
 def setUp(self):
     """Create test setup."""
     # Temporarily disable stderr for these tests, CLI errors clutter up
     # nosetests command.
     self.orig_stderr = sys.stderr
     sys.stderr = HushUpStderr()
     if os.path.isfile(TMP_HOSTFILE):
         os.remove(TMP_HOSTFILE)
     with open(TMP_HOSTFILE, 'w') as test_hostfile:
         test_hostfile.write('1.2.3.4\n')
         test_hostfile.write('1.2.3.[1:10]\n')
Beispiel #6
0
 def setUp(self):
     """Create test setup."""
     # Temporarily disable stderr for these tests, CLI errors clutter up
     # nosetests command.
     self.orig_stderr = sys.stderr
     sys.stderr = HushUpStderr()
     utils.write_server_config({
         'host': '127.0.0.1',
         'port': 8000,
         'use_http': True
     })
Beispiel #7
0
 def setUp(self):
     """Create test setup."""
     write_server_config(DEFAULT_CONFIG)
     # Temporarily disable stderr for these tests, CLI errors clutter up
     # nosetests command.
     self.orig_stderr = sys.stderr
     sys.stderr = HushUpStderr()
     for file in JSON_FILES_LIST:
         if os.path.isfile(file[0]):
             os.remove(file[0])
         with open(file[0], 'w') as test_file:
             test_file.write(file[1])
Beispiel #8
0
    def setUp(self):
        """Create test setup."""
        write_server_config(DEFAULT_CONFIG)
        # Temporarily disable stderr for these tests, CLI errors clutter up
        self.orig_stderr = sys.stderr
        self.success_json = {
            'report_id': 1,
            'report_type': 'insights',
            'report_version': '1.0.0.1b025b8',
            'status': 'completed',
            'report_platform_id': '5f2cc1fd-ec66-4c67-be1b-171a595ce319',
            'hosts': {
                '2f2cc1fd-ec66-4c67-be1b-171a595ce319': {
                    'bios_uuid': 'value'
                }
            }
        }
        self.json_missing_hosts = {
            'report_id': 1,
            'report_type': 'insights',
            'report_version': '1.0.0.1b025b8',
            'status': 'completed',
            'report_platform_id': '5f2cc1fd-ec66-4c67-be1b-171a595ce319',
            'hosts': {}
        }

        sys.stderr = HushUpStderr()
        # pylint:disable=line-too-long
        self.success_effect = [
            (None,
             b'Running Connection Tests...\nConnection test config:\n=== Begin Certificate Chain Test ===\ndepth=1\nverify error:num=0\nverify return:1\ndepth=0\nverify error:num=0\nverify return:1\n=== End Certificate Chain Test: SUCCESS ===\n\n=== Begin Upload URL Connection Test ===\nHTTP Status Code: 200\nHTTP Status Text: OK\nHTTP Response Text: \nSuccessfully connected to: https://cert-api.access.redhat.com/r/insights/uploads/\n=== End Upload URL Connection Test: SUCCESS ===\n\n=== Begin API URL Connection Test ===\nHTTP Status Code: 200\nHTTP Status Text: OK\nHTTP Response Text: lub-dub\nSuccessfully connected to: https://cert-api.access.redhat.com/r/insights/\n=== End API URL Connection Test: SUCCESS ===\n\n\nConnectivity tests completed successfully\nSee /var/log/insights-client/insights-client.log for more details.\n'
             ), (b'Client: 3.0.3-2\nCore: 3.0.72-1\n', b''),
            (None,
             b'Uploading Insights data.\nSuccessfully uploaded report for.\n')
        ]  # noqa: E501

        self.tmp_json_file = '/tmp/insights_tmp_%s.json' % (
            time.strftime('%Y%m%d_%H%M%S'))
        write_file(self.tmp_json_file, json.dumps(self.success_json), False)

        self.tmp_not_json_file = '/tmp/insights_tmp_%s.txt' % (
            time.strftime('%Y%m%d_%H%M%S'))
        write_file(self.tmp_not_json_file, 'not really json', False)

        self.tmp_invalid_insights_json = '/tmp/insights_invalid_tmp_%s.json' % (
            time.strftime('%Y%m%d_%H%M%S'))
        write_file(self.tmp_invalid_insights_json,
                   json.dumps(self.json_missing_hosts), False)
 def setUp(self):
     """Create test setup."""
     write_server_config(DEFAULT_CONFIG)
     # Temporarily disable stderr for these tests, CLI errors clutter up
     # nosetests command.
     self.orig_stderr = sys.stderr
     self.test_json_filename = 'test_%d.json' % time.time()
     self.test_csv_filename = 'test_%d.csv' % time.time()
     sys.stderr = HushUpStderr()
     if os.path.isfile(TMP_DETAILSFILE1):
         os.remove(TMP_DETAILSFILE1)
     with open(TMP_DETAILSFILE1, 'w') as test_details1:
         test_details1.write('{"id": 1, '
                             '"sources": [{"source_name": "source1"}]}')
     if os.path.isfile(TMP_DETAILSFILE2):
         os.remove(TMP_DETAILSFILE2)
     with open(TMP_DETAILSFILE2, 'w') as test_details2:
         test_details2.write('{"id": 1, '
                             '"sources": [{"source_name": "source2"}]}')
     if os.path.isfile(TMP_NOTJSONFILE):
         os.remove(TMP_NOTJSONFILE)
     with open(TMP_NOTJSONFILE, 'w') as test_notjson:
         test_notjson.write('Not a json file.')
Beispiel #10
0
 def setUp(self):
     """Create test setup."""
     # Temporarily disable stderr for these tests, CLI errors clutter up
     # nosetests command.
     self.orig_stderr = sys.stderr
     sys.stderr = HushUpStderr()
Beispiel #11
0
 def setUp(self):
     """Create test setup."""
     write_server_config(DEFAULT_CONFIG)
     self.orig_stderr = sys.stderr
     sys.stderr = HushUpStderr()
     self.url = get_server_location() + ASYNC_MERGE_URI