Пример #1
0
 def test_cve_number_syntax_change(self):
     out = run_wizard(['beaker-wizard',
                       '--current-directory',
                       'wget/Sanity/http/test-it-works',
                       'CVE-2018-123456789'])
     self.assertIn('Bug or CVE numbers : CVE-2018-123456789', out)
     self.assertNotIn('2018-123456789 is not a valid bug or cve number', out)
Пример #2
0
 def test_cve_number_syntax_change(self):
     out = run_wizard(['beaker-wizard',
                       '--current-directory',
                       'wget/Sanity/http/test-it-works',
                       'CVE-2018-123456789'])
     self.assertIn('Bug or CVE numbers : CVE-2018-123456789', out)
     self.assertNotIn('2018-123456789 is not a valid bug or cve number', out)
Пример #3
0
    def test_accepts_non_ascii_gecos(self):
        uid = os.geteuid()
        passwd_file = tempfile.NamedTemporaryFile(
            prefix='beaker-inttest-passwd-', delete=True)
        passwd_file.write(
            textwrap.dedent(u"""\
            svejk:x:{0}:{0}:Josef Švejk:/home/svejk:/sbin/nologin
            """.format(uid).encode('UTF-8')))
        passwd_file.flush()
        group_file = tempfile.NamedTemporaryFile(
            prefix='beaker-inttest-group-', delete=True)
        group_file.write(
            textwrap.dedent(u"""\
            svejk:x:{0}
            """.format(uid).encode('UTF-8')))
        group_file.flush()

        # The bug only occurs on "first run", where beaker-wizard prompts you if
        # the default author name (which it pulls from the GECOS field of
        # passwd) is acceptable.
        out = run_wizard(
            ['beaker-wizard', 'wget/Sanity/test-it-works'],
            cwd=self.tempdir,
            extra_env={
                'BEAKER_WIZARD_CONF': 'some-nonexistent-filename',
                'LD_PRELOAD': 'libnss_wrapper.so',
                'NSS_WRAPPER_PASSWD': passwd_file.name,
                'NSS_WRAPPER_GROUP': group_file.name
            })
        self.assertIn(u'Author : Josef Švejk', out.decode('utf8'))
Пример #4
0
 def test_shows_help_with_nonexistend_command(self):
     """Tests that we don't get a traceback if the user invokes the wizard
     with a nonexistend command."""
     out = run_wizard(['beaker-wizard', 'bogus', '--help'],
                      cwd=self.tempdir)
     self.assertRegexpMatches(out, re.compile(r'\bBeaker Wizard\b', re.I),
                              out)
Пример #5
0
    def test_wizard_guesses_package_from_cwd(self):
        # When run with no args, beaker-wizard guesses the package from the cwd
        # and uses defaults for everything else.
        package = 'bash'
        test_path = os.path.join(self.tempdir, package)
        os.mkdir(test_path)

        out = run_wizard(['beaker-wizard'], cwd=test_path)
        self.assertIn('Package : %s' % package, out)
Пример #6
0
    def test_wizard_guesses_package_from_cwd(self):
        # When run with no args, beaker-wizard guesses the package from the cwd 
        # and uses defaults for everything else.
        package = 'bash'
        test_path = os.path.join(self.tempdir, package)
        os.mkdir(test_path)

        out = run_wizard(['beaker-wizard'], cwd=test_path)
        self.assertIn('Package : %s' % package, out)
Пример #7
0
 def test_rhtsrequired_option(self):
     out = run_wizard(['beaker-wizard', '-Q', 'library(perl/lib1)',
         'http/test-rhtsrequired'],
         cwd=self.tempdir)
     self.assertIn('Required RHTS tests/libraries : library(perl/lib1)', out)
     # assert if it's set properly in the Makefile
     makefile_contents = open(os.path.join(self.tempdir,
             'http', 'test-rhtsrequired', 'Makefile'), 'r').readlines()
     self.assertIn('\t@echo "RhtsRequires:    library(perl/lib1)" >> $(METADATA)\n',
              makefile_contents)
Пример #8
0
    def test_wizard_guesses_values_from_test_name(self):
        # When given a test name, beaker-wizard creates its output in that
        # subdirectory and also guesses some values based on the directory
        # structure. Here we cover each of the possibilities described in the
        # man page.

        # TESTNAME
        out = run_wizard(['beaker-wizard', 'test-it-works'], cwd=self.tempdir)
        self.assertIn('Test name : test-it-works', out)

        # TYPE/TESTNAME
        out = run_wizard(['beaker-wizard', 'Sanity/test-it-works'],
                         cwd=self.tempdir)
        self.assertIn('Test type : Sanity', out)
        self.assertIn('Test name : test-it-works', out)

        # TYPE/PATH/TESTNAME
        out = run_wizard(['beaker-wizard', 'Sanity/http/test-it-works'],
                         cwd=self.tempdir)
        self.assertIn('Test type : Sanity', out)
        self.assertIn('Relative path : http', out)
        self.assertIn('Test name : test-it-works', out)

        # PACKAGE/TYPE/NAME
        out = run_wizard(['beaker-wizard', 'wget/Sanity/test-it-works'],
                         cwd=self.tempdir)
        self.assertIn('Package : wget', out)
        self.assertIn('Test type : Sanity', out)
        self.assertIn('Relative path : None', out)
        self.assertIn('Test name : test-it-works', out)

        # PACKAGE/TYPE/PATH/NAME
        out = run_wizard(['beaker-wizard', 'wget/Sanity/http/test-it-works'],
                         cwd=self.tempdir)
        self.assertIn('Package : wget', out)
        self.assertIn('Test type : Sanity', out)
        self.assertIn('Relative path : http', out)
        self.assertIn('Test name : test-it-works', out)

        # NAMESPACE/PACKAGE/TYPE/NAME
        out = run_wizard(
            ['beaker-wizard', 'distribution/wget/Sanity/test-it-works'],
            cwd=self.tempdir)
        self.assertIn('Namespace : distribution', out)
        self.assertIn('Package : wget', out)
        self.assertIn('Test type : Sanity', out)
        self.assertIn('Relative path : None', out)
        self.assertIn('Test name : test-it-works', out)

        # NAMESPACE/PACKAGE/TYPE/PATH/NAME
        out = run_wizard(
            ['beaker-wizard', 'distribution/wget/Sanity/http/test-it-works'],
            cwd=self.tempdir)
        self.assertIn('Namespace : distribution', out)
        self.assertIn('Package : wget', out)
        self.assertIn('Test type : Sanity', out)
        self.assertIn('Relative path : http', out)
        self.assertIn('Test name : test-it-works', out)
Пример #9
0
 def test_rhtsrequired_option(self):
     out = run_wizard(['beaker-wizard', '-Q', 'library(perl/lib1)',
         'http/test-rhtsrequired'],
         cwd=self.tempdir)
     self.assertIn('Required RHTS tests/libraries : library(perl/lib1)', out)
     # assert if it's set properly in the Makefile
     makefile_contents = open(os.path.join(self.tempdir,
             'http', 'test-rhtsrequired', 'Makefile'), 'r').readlines()
     self.assertIn('\t@echo "RhtsRequires:    library(perl/lib1)" >> $(METADATA)\n',
              makefile_contents)
Пример #10
0
    def test_creates_parametrized_runtest(self):
        out = run_wizard(['beaker-wizard',
                          '-s', 'parametrized',
                          '-o', 'wget,curl',
                          '-q', 'httpd,nginx',
                          'wget/Sanity/test-it-works'], cwd=self.tempdir)

        runtest_contents = open(
            os.path.join(self.tempdir, 'Sanity', 'test-it-works', 'runtest.sh'), 'r').readlines()
        self.assertIn('PACKAGES=${PACKAGES:-curl wget}\n', runtest_contents)
        self.assertIn('REQUIRES=${REQUIRES:-httpd nginx wget}\n', runtest_contents)
Пример #11
0
 def test_accepts_non_ascii_names(self):
     out = run_wizard(['beaker-wizard',
                       '--current-directory',
                       '-n', u'Gęśla Jaźń',
                       '-m', '*****@*****.**'], cwd=self.tempdir)
     self.assertNotIn('is not a valid author', out)
     self.assertIn(u'Author : Gęśla Jaźń', out.decode('utf8'))
     makefile_contents = open(os.path.join(self.tempdir, 'Makefile')).readlines()
     self.assertIn(
             '\t@echo "Owner:           Gęśla Jaźń <*****@*****.**>" > $(METADATA)\n',
             makefile_contents)
Пример #12
0
 def test_accepts_non_ascii_names(self):
     out = run_wizard(['beaker-wizard',
                       '--current-directory',
                       '-n', u'Gęśla Jaźń'.encode('utf8'),
                       '-m', '*****@*****.**'], cwd=self.tempdir)
     self.assertNotIn('is not a valid author', out)
     self.assertIn(u'Author : Gęśla Jaźń', out.decode('utf8'))
     makefile_contents = open(os.path.join(self.tempdir, 'Makefile')).readlines()
     self.assertIn(
             '\t@echo "Owner:           Gęśla Jaźń <*****@*****.**>" > $(METADATA)\n',
             makefile_contents)
Пример #13
0
    def test_creates_parametrized_runtest(self):
        out = run_wizard(['beaker-wizard',
                          '-s', 'parametrized',
                          '-o', 'wget,curl',
                          '-q', 'httpd,nginx',
                          'wget/Sanity/test-it-works'], cwd=self.tempdir)

        runtest_contents = open(
            os.path.join(self.tempdir, 'Sanity', 'test-it-works', 'runtest.sh'), 'r').readlines()
        self.assertIn('PACKAGES=${PACKAGES:-curl wget}\n', runtest_contents)
        self.assertIn('REQUIRES=${REQUIRES:-httpd nginx wget}\n', runtest_contents)
Пример #14
0
    def test_wizard_creates_test_in_current_directory(self):
        out = run_wizard(['beaker-wizard',
                          '--current-directory',
                          'wget/Sanity/http/test-it-works'], cwd=self.tempdir)

        self.assertIn('File ./runtest.sh written', out)
        self.assertIn('File ./Makefile written', out)
        self.assertIn('File ./PURPOSE written', out)
        self.assertIn('Package : wget', out)
        self.assertIn('Test type : Sanity', out)
        self.assertIn('Relative path : http', out)
        self.assertIn('Test name : test-it-works', out)

        runtest_contents = open(
            os.path.join(self.tempdir, 'runtest.sh'), 'r').readlines()
        self.assertIn('PACKAGE="wget"\n', runtest_contents)
Пример #15
0
    def test_wizard_creates_test_in_current_directory(self):
        out = run_wizard(['beaker-wizard',
                          '--current-directory',
                          'wget/Sanity/http/test-it-works'], cwd=self.tempdir)

        self.assertIn('File ./runtest.sh written', out)
        self.assertIn('File ./Makefile written', out)
        self.assertIn('File ./PURPOSE written', out)
        self.assertIn('Package : wget', out)
        self.assertIn('Test type : Sanity', out)
        self.assertIn('Relative path : http', out)
        self.assertIn('Test name : test-it-works', out)

        runtest_contents = open(
            os.path.join(self.tempdir, 'runtest.sh'), 'r').readlines()
        self.assertIn('PACKAGE="wget"\n', runtest_contents)
Пример #16
0
    def test_wizard_guesses_values_from_test_name(self):
        # When given a test name, beaker-wizard creates its output in that 
        # subdirectory and also guesses some values based on the directory 
        # structure. Here we cover each of the possibilities described in the 
        # man page.

        # TESTNAME
        out = run_wizard(['beaker-wizard', 'test-it-works'], cwd=self.tempdir)
        self.assertIn('Test name : test-it-works', out)

        # TYPE/TESTNAME
        out = run_wizard(['beaker-wizard', 'Sanity/test-it-works'], cwd=self.tempdir)
        self.assertIn('Test type : Sanity', out)
        self.assertIn('Test name : test-it-works', out)

        # TYPE/PATH/TESTNAME
        out = run_wizard(['beaker-wizard', 'Sanity/http/test-it-works'], cwd=self.tempdir)
        self.assertIn('Test type : Sanity', out)
        self.assertIn('Relative path : http', out)
        self.assertIn('Test name : test-it-works', out)

        # PACKAGE/TYPE/NAME
        out = run_wizard(['beaker-wizard', 'wget/Sanity/test-it-works'], cwd=self.tempdir)
        self.assertIn('Package : wget', out)
        self.assertIn('Test type : Sanity', out)
        self.assertIn('Relative path : None', out)
        self.assertIn('Test name : test-it-works', out)

        # PACKAGE/TYPE/PATH/NAME
        out = run_wizard(['beaker-wizard', 'wget/Sanity/http/test-it-works'], cwd=self.tempdir)
        self.assertIn('Package : wget', out)
        self.assertIn('Test type : Sanity', out)
        self.assertIn('Relative path : http', out)
        self.assertIn('Test name : test-it-works', out)

        # NAMESPACE/PACKAGE/TYPE/NAME
        out = run_wizard(['beaker-wizard', 'distribution/wget/Sanity/test-it-works'], cwd=self.tempdir)
        self.assertIn('Namespace : distribution', out)
        self.assertIn('Package : wget', out)
        self.assertIn('Test type : Sanity', out)
        self.assertIn('Relative path : None', out)
        self.assertIn('Test name : test-it-works', out)

        # NAMESPACE/PACKAGE/TYPE/PATH/NAME
        out = run_wizard(['beaker-wizard', 'distribution/wget/Sanity/http/test-it-works'], cwd=self.tempdir)
        self.assertIn('Namespace : distribution', out)
        self.assertIn('Package : wget', out)
        self.assertIn('Test type : Sanity', out)
        self.assertIn('Relative path : http', out)
        self.assertIn('Test name : test-it-works', out)
Пример #17
0
    def test_accepts_non_ascii_gecos(self):
        uid = os.geteuid()
        passwd_file = tempfile.NamedTemporaryFile(prefix='beaker-inttest-passwd-', delete=True)
        passwd_file.write(textwrap.dedent(u"""\
            svejk:x:{0}:{0}:Josef Švejk:/home/svejk:/sbin/nologin
            """.format(uid).encode('UTF-8')))
        passwd_file.flush()
        group_file = tempfile.NamedTemporaryFile(prefix='beaker-inttest-group-', delete=True)
        group_file.write(textwrap.dedent(u"""\
            svejk:x:{0}
            """.format(uid).encode('UTF-8')))
        group_file.flush()

        # The bug only occurs on "first run", where beaker-wizard prompts you if
        # the default author name (which it pulls from the GECOS field of
        # passwd) is acceptable.
        out = run_wizard(['beaker-wizard', 'wget/Sanity/test-it-works'],
                         cwd=self.tempdir,
                         extra_env={'BEAKER_WIZARD_CONF': 'some-nonexistent-filename',
                                    'LD_PRELOAD': 'libnss_wrapper.so',
                                    'NSS_WRAPPER_PASSWD': passwd_file.name,
                                    'NSS_WRAPPER_GROUP': group_file.name})
        self.assertIn(u'Author : Josef Švejk', out.decode('utf8'))
Пример #18
0
 def test_creates_successfully_custom_test_type(self):
     out = run_wizard(['beaker-wizard', 'http/test1'], cwd=self.tempdir)
     self.assertIn('Test type : http', out)
     self.assertIn('Relative path : None', out)
     self.assertIn('Test name : test1', out)
Пример #19
0
 def test_shows_help_successfully(self):
     out = run_wizard(['beaker-wizard', '--help'])
     self.assertRegexpMatches(out, re.compile(r'\bBeaker Wizard\b', re.I),
                              out)
Пример #20
0
 def test_creates_successfully_custom_test_type(self):
     out = run_wizard(['beaker-wizard', 'http/test1'], cwd=self.tempdir)
     self.assertIn('Test type : http', out)
     self.assertIn('Relative path : None', out)
     self.assertIn('Test name : test1', out)
Пример #21
0
 def test_shows_help_successfully(self):
     out = run_wizard(['beaker-wizard', '--help'])
     self.assertRegexpMatches(out, re.compile(r'\bBeaker Wizard\b', re.I), out)
Пример #22
0
 def test_shows_help_with_nonexistend_command(self):
     """Tests that we don't get a traceback if the user invokes the wizard
     with a nonexistend command."""
     out = run_wizard(['beaker-wizard', 'bogus', '--help'], cwd=self.tempdir)
     self.assertRegexpMatches(out, re.compile(r'\bBeaker Wizard\b', re.I), out)