Example #1
0
    def test_build_composer_environment_inherits_from_ctx(self):
        ctx = utils.FormattedDict({
            'BP_DIR': '',
            'BUILD_DIR': '/usr/awesome',
            'WEBDIR': '',
            'PHPRC': '/usr/awesome/phpini',
            'PHP_VM': 'php',
            'TMPDIR': 'tmp',
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
            'OUR_SPECIAL_KEY': 'SPECIAL_VALUE'
        })

        environ_stub = Dingus()
        environ_stub._set_return_value(['OUR_SPECIAL_KEY'])

        write_config_stub = Dingus()

        with patches({
                'os.environ.keys':
                environ_stub,
                'composer.extension.PHPComposerStrategy.write_config':
                write_config_stub
        }):

            self.extension_module.ComposerExtension(ctx)
            cr = self.extension_module.ComposerCommandRunner(ctx, None)

            built_environment = cr._build_composer_environment()

        assert 'OUR_SPECIAL_KEY' in built_environment, \
            'OUR_SPECIAL_KEY was not found in the built_environment variable'
        assert built_environment['OUR_SPECIAL_KEY'] == 'SPECIAL_VALUE',  \
            '"OUR_SPECIAL_KEY" key in built_environment was %s; expected "SPECIAL_VALUE"' % built_environment['OUR_SPECIAL_KEY']
    def test_github_oauth_token_is_valid_uses_curl(self):
        ctx = utils.FormattedDict({
            'BUILD_DIR': '/usr/awesome',
            'PHP_VM': 'php',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
        })

        instance_stub = Dingus()
        instance_stub._set_return_value("""{"resources": {}}""")

        stream_output_stub = Dingus(
            'test_github_oauth_token_uses_curl : stream_output')

        with patches({
            'StringIO.StringIO.getvalue': instance_stub,
            'composer.extension.stream_output': stream_output_stub,
        }):
            ct = self.extension_module.ComposerExtension(ctx)
            ct._github_oauth_token_is_valid('MADE_UP_TOKEN_VALUE')
            executed_command = stream_output_stub.calls()[0].args[1]

        assert stream_output_stub.calls().once(), \
            'stream_output() was called more than once'
        assert executed_command.find('curl') == 0, \
            'Curl was not called, executed_command was %s' % executed_command
        assert executed_command.find(
            '-H "Authorization: token MADE_UP_TOKEN_VALUE"') > 0, \
            'No token was passed to curl. Command was: %s' % executed_command
        assert executed_command.find('https://api.github.com/rate_limit') > 0,\
            'No URL was passed to curl. Command was: %s' % executed_command
Example #3
0
    def test_github_download_rate_is_exceeded(self):  # noqa
        ctx = utils.FormattedDict({
            'BUILD_DIR': tempfile.gettempdir(),
            'PHP_VM': 'php',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
            'WEBDIR': ''
        })

        instance_stub = Dingus()
        instance_stub._set_return_value("""{"rate": {"limit": 60, "remaining": 0}}""")

        stream_output_stub = Dingus(
            'test_github_oauth_token_uses_curl : stream_output')

        with patches({
            'StringIO.StringIO.getvalue': instance_stub,
            'composer.extension.stream_output': stream_output_stub,
        }):
            ct = self.extension_module.ComposerExtension(ctx)
            result = ct._github_rate_exceeded(False)

        assert result is True, \
            '_github_oauth_token_is_valid returned %s, expected True' % result
Example #4
0
    def test_github_download_rate_is_exceeded(self):  # noqa
        ctx = utils.FormattedDict({
            'BP_DIR': '',
            'BUILD_DIR': tempfile.gettempdir(),
            'PHP_VM': 'php',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
            'WEBDIR': ''
        })

        instance_stub = Dingus()
        instance_stub._set_return_value(
            """{"rate": {"limit": 60, "remaining": 0}}""")

        stream_output_stub = Dingus(
            'test_github_oauth_token_uses_curl : stream_output')

        with patches({
                'StringIO.StringIO.getvalue': instance_stub,
                'composer.extension.stream_output': stream_output_stub,
        }):
            ct = self.extension_module.ComposerExtension(ctx)
            result = ct._github_rate_exceeded(False)

        assert result is True, \
            '_github_oauth_token_is_valid returned %s, expected True' % result
Example #5
0
    def test_github_oauth_token_is_valid_interprets_github_api_401_as_false(
            self):  # noqa
        ctx = utils.FormattedDict({
            'BP_DIR': '',
            'BUILD_DIR': tempfile.gettempdir(),
            'PHP_VM': 'php',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
            'WEBDIR': ''
        })

        instance_stub = Dingus()
        instance_stub._set_return_value("""{}""")

        stream_output_stub = Dingus(
            'test_github_oauth_token_uses_curl : stream_output')

        with patches({
                'StringIO.StringIO.getvalue': instance_stub,
                'composer.extension.stream_output': stream_output_stub,
        }):
            ct = self.extension_module.ComposerExtension(ctx)
            result = ct._github_oauth_token_is_valid('MADE_UP_TOKEN_VALUE')

        assert result is False, \
            '_github_oauth_token_is_valid returned %s, expected False' % result
Example #6
0
    def test_build_composer_environment_inherits_from_ctx(self):
        ctx = utils.FormattedDict(
            {
                "BUILD_DIR": "/usr/awesome",
                "WEBDIR": "",
                "PHPRC": "/usr/awesome/phpini",
                "PHP_VM": "php",
                "TMPDIR": "tmp",
                "LIBDIR": "lib",
                "CACHE_DIR": "cache",
                "OUR_SPECIAL_KEY": "SPECIAL_VALUE",
            }
        )

        environ_stub = Dingus()
        environ_stub._set_return_value(["OUR_SPECIAL_KEY"])

        write_config_stub = Dingus()

        with patches(
            {"os.environ.keys": environ_stub, "composer.extension.PHPComposerStrategy.write_config": write_config_stub}
        ):

            self.extension_module.ComposerExtension(ctx)
            cr = self.extension_module.ComposerCommandRunner(ctx, None)

            built_environment = cr._build_composer_environment()

        assert "OUR_SPECIAL_KEY" in built_environment, "OUR_SPECIAL_KEY was not found in the built_environment variable"
        assert built_environment["OUR_SPECIAL_KEY"] == "SPECIAL_VALUE", (
            '"OUR_SPECIAL_KEY" key in built_environment was %s; expected "SPECIAL_VALUE"'
            % built_environment["OUR_SPECIAL_KEY"]
        )
Example #7
0
    def test_github_oauth_token_is_valid_uses_curl(self):
        ctx = utils.FormattedDict(
            {
                "BUILD_DIR": "/usr/awesome",
                "PHP_VM": "php",
                "TMPDIR": tempfile.gettempdir(),
                "LIBDIR": "lib",
                "CACHE_DIR": "cache",
                "WEBDIR": "",
            }
        )

        instance_stub = Dingus()
        instance_stub._set_return_value("""{"resources": {}}""")

        stream_output_stub = Dingus("test_github_oauth_token_uses_curl : stream_output")

        with patches(
            {"StringIO.StringIO.getvalue": instance_stub, "composer.extension.stream_output": stream_output_stub}
        ):
            ct = self.extension_module.ComposerExtension(ctx)
            ct._github_oauth_token_is_valid("MADE_UP_TOKEN_VALUE")
            executed_command = stream_output_stub.calls()[0].args[1]

        assert stream_output_stub.calls().once(), "stream_output() was called more than once"
        assert executed_command.find("curl") == 0, "Curl was not called, executed_command was %s" % executed_command
        assert executed_command.find('-H "Authorization: token MADE_UP_TOKEN_VALUE"') > 0, (
            "No token was passed to curl. Command was: %s" % executed_command
        )
        assert executed_command.find("https://api.github.com/rate_limit") > 0, (
            "No URL was passed to curl. Command was: %s" % executed_command
        )
    def test_build_composer_environment_inherits_from_ctx(self):
        ctx = utils.FormattedDict({
            'BUILD_DIR': '/usr/awesome',
            'PHPRC': '/usr/awesome/phpini',
            'PHP_VM': 'php',
            'TMPDIR': 'tmp',
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
            'OUR_SPECIAL_KEY': 'SPECIAL_VALUE'
        })

        environ_stub = Dingus()
        environ_stub._set_return_value(['OUR_SPECIAL_KEY'])

        write_config_stub = Dingus()

        with patches({
            'os.environ.keys': environ_stub,
            'composer.extension.PHPComposerStrategy.write_config': write_config_stub
        }):

            self.extension_module.ComposerExtension(ctx)
            cr = self.extension_module.ComposerCommandRunner(ctx, None)

            built_environment = cr._build_composer_environment()

        assert 'OUR_SPECIAL_KEY' in built_environment, \
            'OUR_SPECIAL_KEY was not found in the built_environment variable'
        assert built_environment['OUR_SPECIAL_KEY'] == 'SPECIAL_VALUE',  \
            '"OUR_SPECIAL_KEY" key in built_environment was %s; expected "SPECIAL_VALUE"' % built_environment['OUR_SPECIAL_KEY']
Example #9
0
    def test_github_oauth_token_is_valid_interprets_github_api_401_as_false(self):  # noqa
        ctx = utils.FormattedDict({
            'BUILD_DIR': tempfile.gettempdir(),
            'PHP_VM': 'php',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
            'WEBDIR': ''
        })

        instance_stub = Dingus()
        instance_stub._set_return_value("""{}""")

        stream_output_stub = Dingus(
            'test_github_oauth_token_uses_curl : stream_output')

        with patches({
            'StringIO.StringIO.getvalue': instance_stub,
            'composer.extension.stream_output': stream_output_stub,
        }):
            ct = self.extension_module.ComposerExtension(ctx)
            result = ct._github_oauth_token_is_valid('MADE_UP_TOKEN_VALUE')

        assert result is False, \
            '_github_oauth_token_is_valid returned %s, expected False' % result
Example #10
0
    def test_github_oauth_token_is_valid_uses_curl(self):
        ctx = utils.FormattedDict({
            'BP_DIR': '',
            'BUILD_DIR': '/usr/awesome',
            'PHP_VM': 'php',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
            'WEBDIR': ''
        })

        instance_stub = Dingus()
        instance_stub._set_return_value("""{"resources": {}}""")

        stream_output_stub = Dingus(
            'test_github_oauth_token_uses_curl : stream_output')

        with patches({
                'StringIO.StringIO.getvalue': instance_stub,
                'composer.extension.stream_output': stream_output_stub,
        }):
            ct = self.extension_module.ComposerExtension(ctx)
            ct._github_oauth_token_is_valid('MADE_UP_TOKEN_VALUE')
            executed_command = stream_output_stub.calls()[0].args[1]

        assert stream_output_stub.calls().once(), \
            'stream_output() was called more than once'
        assert executed_command.find('curl') == 0, \
            'Curl was not called, executed_command was %s' % executed_command
        assert executed_command.find(
            '-H "Authorization: token MADE_UP_TOKEN_VALUE"') > 0, \
            'No token was passed to curl. Command was: %s' % executed_command
        assert executed_command.find('https://api.github.com/rate_limit') > 0,\
            'No URL was passed to curl. Command was: %s' % executed_command
Example #11
0
    def test_run_sets_github_oauth_token_if_present(self):
        ctx = utils.FormattedDict({
            'DOWNLOAD_URL':
            'http://server/bins',
            'CACHE_HASH_ALGORITHM':
            'sha1',
            'BUILD_DIR':
            '/usr/awesome',
            'PHP_VM':
            'php',
            'TMPDIR':
            tempfile.gettempdir(),
            'LIBDIR':
            'lib',
            'CACHE_DIR':
            'cache',
            'COMPOSER_GITHUB_OAUTH_TOKEN':
            'MADE_UP_TOKEN_VALUE'
        })

        stream_output_stub = Dingus()
        old_stream_output = self.extension_module.stream_output
        self.extension_module.stream_output = stream_output_stub

        old_rewrite = self.extension_module.utils.rewrite_cfgs
        rewrite = Dingus()
        self.extension_module.utils.rewrite_cfgs = rewrite

        old_environment = os.environ
        os.environ = {'COMPOSER_GITHUB_OAUTH_TOKEN': 'MADE_UP_TOKEN_VALUE'}

        try:
            ct = self.extension_module.ComposerExtension(ctx)

            builder_stub = Dingus(_ctx=ctx)
            ct._builder = builder_stub

            github_oauth_token_is_valid_stub = Dingus(
                'test_run_sets_github_oauth_token_if_present:github_oauth_token_is_valid_stub'
            )
            github_oauth_token_is_valid_stub._set_return_value(True)
            ct._github_oauth_token_is_valid = github_oauth_token_is_valid_stub

            ct.run()

            executed_command = stream_output_stub.calls()[0].args[1]
        finally:
            self.extension_module.stream_output = old_stream_output
            self.extension_module.utils.rewrite_cfgs = old_rewrite
            os.environ = old_environment

        assert executed_command.find('config') > 0, 'did not see "config"'
        assert executed_command.find('-g') > 0, 'did not see "-g"'
        assert executed_command.find(
            'github-oauth.github.com'
        ) > 0, 'did not see "github-oauth.github.com"'
        assert executed_command.find(
            '"MADE_UP_TOKEN_VALUE"') > 0, 'did not see "MADE_UP_TOKEN_VALUE"'
Example #12
0
    def test_composer_tool_run_custom_composer_opts(self):
        ctx = utils.FormattedDict({
            'PHP_VM':
            'php',
            'DOWNLOAD_URL':
            'http://server/bins',
            'CACHE_HASH_ALGORITHM':
            'sha1',
            'BUILD_DIR':
            '/build/dir',
            'CACHE_DIR':
            '/cache/dir',
            'TMPDIR':
            tempfile.gettempdir(),
            'WEBDIR':
            'htdocs',
            'LIBDIR':
            'lib',
            'COMPOSER_INSTALL_OPTIONS': ['--optimize-autoloader'],
            'BP_DIR':
            ''
        })

        instance_stub = Dingus()
        instance_stub._set_return_value(
            """{"rate": {"limit": 60, "remaining": 60}}""")

        stream_output_stub = Dingus()

        rewrite_stub = Dingus()

        builder = Dingus(_ctx=ctx)

        with patches({
                'StringIO.StringIO.getvalue': instance_stub,
                'composer.extension.stream_output': stream_output_stub,
                'composer.extension.utils.rewrite_cfgs': rewrite_stub
        }):
            ct = self.extension_module.ComposerExtension(ctx)
            ct._builder = builder
            ct.composer_runner = \
                self.extension_module.ComposerCommandRunner(ctx, builder)
            ct.run()
            eq_(2, len(builder.move.calls()))
            eq_(1, len(builder.copy.calls()))
            assert rewrite_stub.calls().once()
            rewrite_args = rewrite_stub.calls()[0].args
            assert rewrite_args[0].endswith('php.ini')
            assert 'HOME' in rewrite_args[1]
            assert 'TMPDIR' in rewrite_args[1]
            instCmd = stream_output_stub.calls()[-1].args[1]
            assert instCmd.find('--optimize-autoloader') > 0
Example #13
0
    def test_composer_tool_run_sanity_checks(self):
        ctx = utils.FormattedDict({
            'PHP_VM': 'php',
            'DOWNLOAD_URL': 'http://server/bins',
            'CACHE_HASH_ALGORITHM': 'sha1',
            'BUILD_DIR': '/build/dir',
            'CACHE_DIR': '/cache/dir',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'BP_DIR': ''
        })

        instance_stub = Dingus()
        instance_stub._set_return_value(
            """{"rate": {"limit": 60, "remaining": 60}}""")

        stream_output_stub = Dingus()

        rewrite_stub = Dingus()

        builder = Dingus(_ctx=ctx)

        exists_stub = Dingus()

        with patches({
                'StringIO.StringIO.getvalue': instance_stub,
                'composer.extension.stream_output': stream_output_stub,
                'composer.extension.utils.rewrite_cfgs': rewrite_stub
        }):
            composer_extension = \
                self.extension_module.ComposerExtension(ctx)
            composer_extension._log = Dingus()
            composer_extension._builder = builder
            composer_extension.composer_runner = \
                self.extension_module.ComposerCommandRunner(ctx, builder)

            composer_extension.run()

            composer_extension_calls = composer_extension._log.warning.calls()
            assert len(composer_extension_calls) > 0
            assert composer_extension_calls[0].args[0].find('PROTIP:') == 0
            exists = Dingus(return_value=True)
            with patch('os.path.exists', exists_stub):
                composer_extension._log = Dingus()
                composer_extension.run()
            assert len(exists_stub.calls()) == 2
            assert len(composer_extension._log.warning.calls()) == 0
Example #14
0
    def test_composer_tool_run_sanity_checks(self):
        ctx = utils.FormattedDict(
            {
                "PHP_VM": "php",
                "BUILD_DIR": "/build/dir",
                "CACHE_DIR": "/cache/dir",
                "WEBDIR": "",
                "TMPDIR": tempfile.gettempdir(),
                "LIBDIR": "lib",
                "BP_DIR": "",
            }
        )

        instance_stub = Dingus()
        instance_stub._set_return_value("""{"rate": {"limit": 60, "remaining": 60}}""")

        stream_output_stub = Dingus()

        rewrite_stub = Dingus()

        builder = Dingus(_ctx=ctx)

        exists_stub = Dingus()

        with patches(
            {
                "StringIO.StringIO.getvalue": instance_stub,
                "composer.extension.stream_output": stream_output_stub,
                "composer.extension.utils.rewrite_cfgs": rewrite_stub,
            }
        ):
            composer_extension = self.extension_module.ComposerExtension(ctx)
            composer_extension._log = Dingus()
            composer_extension._builder = builder
            composer_extension.composer_runner = self.extension_module.ComposerCommandRunner(ctx, builder)

            composer_extension.run()

            composer_extension_calls = composer_extension._log.warning.calls()
            assert len(composer_extension_calls) > 0
            assert composer_extension_calls[0].args[0].find("PROTIP:") == 0
            exists = Dingus(return_value=True)
            with patch("os.path.exists", exists_stub):
                composer_extension._log = Dingus()
                composer_extension.run()
            assert len(composer_extension._log.warning.calls()) == 0
    def test_composer_tool_run_sanity_checks(self):
        ctx = utils.FormattedDict({
            'PHP_VM': 'php',
            'DOWNLOAD_URL': 'http://server/bins',
            'CACHE_HASH_ALGORITHM': 'sha1',
            'BUILD_DIR': '/build/dir',
            'CACHE_DIR': '/cache/dir',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'BP_DIR': ''
        })

        instance_stub = Dingus()
        instance_stub._set_return_value("""{"rate": {"limit": 60, "remaining": 60}}""")

        stream_output_stub = Dingus()

        rewrite_stub = Dingus()

        builder = Dingus(_ctx=ctx)
        
        exists_stub = Dingus()

        with patches({
            'StringIO.StringIO.getvalue': instance_stub,
            'composer.extension.stream_output': stream_output_stub,
            'composer.extension.utils.rewrite_cfgs': rewrite_stub
        }):
            composer_extension = \
                self.extension_module.ComposerExtension(ctx)
            composer_extension._log = Dingus()
            composer_extension._builder = builder
            composer_extension.composer_runner = \
                self.extension_module.ComposerCommandRunner(ctx, builder)

            composer_extension.run()

            composer_extension_calls = composer_extension._log.warning.calls()
            assert len(composer_extension_calls) > 0
            assert composer_extension_calls[0].args[0].find('PROTIP:') == 0
            exists = Dingus(return_value=True)
            with patch('os.path.exists', exists_stub):
                composer_extension._log = Dingus()
                composer_extension.run()
            assert len(exists_stub.calls()) == 2
            assert len(composer_extension._log.warning.calls()) == 0
    def test_run_sets_github_oauth_token_if_present(self):
        ctx = utils.FormattedDict({
            'DOWNLOAD_URL': 'http://server/bins',
            'CACHE_HASH_ALGORITHM': 'sha1',
            'BUILD_DIR': '/usr/awesome',
            'PHP_VM': 'php',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
            'COMPOSER_GITHUB_OAUTH_TOKEN': 'MADE_UP_TOKEN_VALUE'
        })

        stream_output_stub = Dingus()
        old_stream_output = self.extension_module.stream_output
        self.extension_module.stream_output = stream_output_stub

        old_rewrite = self.extension_module.utils.rewrite_cfgs
        rewrite = Dingus()
        self.extension_module.utils.rewrite_cfgs = rewrite

        old_environment = os.environ
        os.environ = { 'COMPOSER_GITHUB_OAUTH_TOKEN': 'MADE_UP_TOKEN_VALUE'}

        try:
            ct = self.extension_module.ComposerExtension(ctx)

            builder_stub = Dingus(_ctx=ctx)
            ct._builder = builder_stub

            github_oauth_token_is_valid_stub = Dingus('test_run_sets_github_oauth_token_if_present:github_oauth_token_is_valid_stub')
            github_oauth_token_is_valid_stub._set_return_value(True)
            ct._github_oauth_token_is_valid = github_oauth_token_is_valid_stub

            ct.run()

            executed_command = stream_output_stub.calls()[0].args[1]
        finally:
            self.extension_module.stream_output = old_stream_output
            self.extension_module.utils.rewrite_cfgs = old_rewrite
            os.environ = old_environment

        assert executed_command.find('config') > 0, 'did not see "config"'
        assert executed_command.find('-g') > 0, 'did not see "-g"'
        assert executed_command.find('github-oauth.github.com') > 0, 'did not see "github-oauth.github.com"'
        assert executed_command.find('"MADE_UP_TOKEN_VALUE"') > 0, 'did not see "MADE_UP_TOKEN_VALUE"'
Example #17
0
    def test_no_github_api_call_with_cached_buildpack(self):
        ctx = utils.FormattedDict({
            'BUILD_DIR': tempfile.gettempdir(),
            'PHP_VM': 'php',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
            'BP_DIR': '',
            'WEBDIR': ''
        })

        builder = Dingus(_ctx=ctx)

        path_exists_stub = Dingus()
        path_exists_stub._set_return_value(True)

        setup_composer_github_token_stub = Dingus()
        check_github_rate_exceeded_stub = Dingus()

        rewrite_stub = Dingus()

        stream_output_stub = Dingus(
            'test_github_oauth_token_uses_curl : stream_output')
        with patches({
                'os.path.exists':
                path_exists_stub,
                'composer.extension.ComposerExtension.setup_composer_github_token':
                setup_composer_github_token_stub,
                'composer.extension.ComposerExtension.check_github_rate_exceeded':
                check_github_rate_exceeded_stub,
                'composer.extension.utils.rewrite_cfgs':
                rewrite_stub,
                'composer.extension.stream_output':
                stream_output_stub
        }):
            ct = self.extension_module.ComposerExtension(ctx)
            ct._builder = builder
            ct.composer_runner = \
                    self.extension_module.ComposerCommandRunner(ctx, builder)
            ct.run()

        assert 0 == len(setup_composer_github_token_stub.calls()), \
                'setup_composer_github_token was called, expected no calls'
        assert 0 == len(check_github_rate_exceeded_stub.calls()), \
                'check_github_rate_exceeded was called, expected no calls'
Example #18
0
    def test_run_does_not_set_github_oauth_if_missing(self):
        ctx = utils.FormattedDict({
            'DOWNLOAD_URL': 'http://server/bins',
            'CACHE_HASH_ALGORITHM': 'sha1',
            'BUILD_DIR': '/usr/awesome',
            'PHP_VM': 'php',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
            'BP_DIR': ''
        })
        instance_stub = Dingus()
        instance_stub._set_return_value(
            """{"rate": {"limit": 60, "remaining": 60}}""")

        stream_output_stub = Dingus()

        rewrite_stub = Dingus()

        builder = Dingus(_ctx=ctx)

        setup_composer_github_token_stub = Dingus()

        with patches({
                'StringIO.StringIO.getvalue':
                instance_stub,
                'composer.extension.stream_output':
                stream_output_stub,
                'composer.extension.utils.rewrite_cfgs':
                rewrite_stub,
                'composer.extension.ComposerExtension.setup_composer_github_token':
                setup_composer_github_token_stub
        }):
            ct = self.extension_module.ComposerExtension(ctx)

            ct._builder = builder
            ct.composer_runner = \
                self.extension_module.ComposerCommandRunner(ctx, builder)
            ct.run()

            setup_composer_github_token_calls = setup_composer_github_token_stub.calls(
            )

        assert 0 == len(setup_composer_github_token_calls), \
            'setup_composer_github_token() was called %s times, expected 0' % len(setup_composer_github_token_calls)
Example #19
0
    def test_no_github_api_call_with_cached_buildpack(self):
        ctx = utils.FormattedDict(
            {
                "BUILD_DIR": tempfile.gettempdir(),
                "PHP_VM": "php",
                "TMPDIR": tempfile.gettempdir(),
                "LIBDIR": "lib",
                "CACHE_DIR": "cache",
                "BP_DIR": "",
                "WEBDIR": "",
            }
        )

        builder = Dingus(_ctx=ctx)

        path_exists_stub = Dingus()
        path_exists_stub._set_return_value(True)

        setup_composer_github_token_stub = Dingus()
        check_github_rate_exceeded_stub = Dingus()

        rewrite_stub = Dingus()

        stream_output_stub = Dingus("test_github_oauth_token_uses_curl : stream_output")
        with patches(
            {
                "os.path.exists": path_exists_stub,
                "composer.extension.ComposerExtension.setup_composer_github_token": setup_composer_github_token_stub,
                "composer.extension.ComposerExtension.check_github_rate_exceeded": check_github_rate_exceeded_stub,
                "composer.extension.utils.rewrite_cfgs": rewrite_stub,
                "composer.extension.stream_output": stream_output_stub,
            }
        ):
            ct = self.extension_module.ComposerExtension(ctx)
            ct._builder = builder
            ct.composer_runner = self.extension_module.ComposerCommandRunner(ctx, builder)
            ct.run()

        assert 0 == len(
            setup_composer_github_token_stub.calls()
        ), "setup_composer_github_token was called, expected no calls"
        assert 0 == len(
            check_github_rate_exceeded_stub.calls()
        ), "check_github_rate_exceeded was called, expected no calls"
Example #20
0
    def test_composer_tool_run_custom_composer_opts(self):
        ctx = utils.FormattedDict(
            {
                "PHP_VM": "php",
                "BUILD_DIR": "/build/dir",
                "CACHE_DIR": "/cache/dir",
                "TMPDIR": tempfile.gettempdir(),
                "WEBDIR": "htdocs",
                "LIBDIR": "lib",
                "COMPOSER_INSTALL_OPTIONS": ["--optimize-autoloader"],
                "BP_DIR": "",
            }
        )

        instance_stub = Dingus()
        instance_stub._set_return_value("""{"rate": {"limit": 60, "remaining": 60}}""")

        stream_output_stub = Dingus()

        rewrite_stub = Dingus()

        builder = Dingus(_ctx=ctx)

        with patches(
            {
                "StringIO.StringIO.getvalue": instance_stub,
                "composer.extension.stream_output": stream_output_stub,
                "composer.extension.utils.rewrite_cfgs": rewrite_stub,
            }
        ):
            ct = self.extension_module.ComposerExtension(ctx)
            ct._builder = builder
            ct.composer_runner = self.extension_module.ComposerCommandRunner(ctx, builder)
            ct.run()
            eq_(1, len(builder.copy.calls()))
            assert rewrite_stub.calls().once()
            rewrite_args = rewrite_stub.calls()[0].args
            assert rewrite_args[0].endswith("php.ini")
            assert "HOME" in rewrite_args[1]
            assert "TMPDIR" in rewrite_args[1]
            instCmd = stream_output_stub.calls()[-1].args[1]
            assert instCmd.find("--optimize-autoloader") > 0
Example #21
0
    def test_run_does_not_set_github_oauth_if_missing(self):
        ctx = utils.FormattedDict(
            {
                "BUILD_DIR": "/usr/awesome",
                "PHP_VM": "php",
                "TMPDIR": tempfile.gettempdir(),
                "LIBDIR": "lib",
                "CACHE_DIR": "cache",
                "BP_DIR": "",
                "WEBDIR": "",
            }
        )
        instance_stub = Dingus()
        instance_stub._set_return_value("""{"rate": {"limit": 60, "remaining": 60}}""")

        stream_output_stub = Dingus()

        rewrite_stub = Dingus()

        builder = Dingus(_ctx=ctx)

        setup_composer_github_token_stub = Dingus()

        with patches(
            {
                "StringIO.StringIO.getvalue": instance_stub,
                "composer.extension.stream_output": stream_output_stub,
                "composer.extension.utils.rewrite_cfgs": rewrite_stub,
                "composer.extension.ComposerExtension.setup_composer_github_token": setup_composer_github_token_stub,
            }
        ):
            ct = self.extension_module.ComposerExtension(ctx)

            ct._builder = builder
            ct.composer_runner = self.extension_module.ComposerCommandRunner(ctx, builder)
            ct.run()

            setup_composer_github_token_calls = setup_composer_github_token_stub.calls()

        assert 0 == len(
            setup_composer_github_token_calls
        ), "setup_composer_github_token() was called %s times, expected 0" % len(setup_composer_github_token_calls)
    def test_composer_tool_run_custom_composer_opts(self):
        ctx = utils.FormattedDict({
            'PHP_VM': 'php',
            'DOWNLOAD_URL': 'http://server/bins',
            'CACHE_HASH_ALGORITHM': 'sha1',
            'BUILD_DIR': '/build/dir',
            'CACHE_DIR': '/cache/dir',
            'TMPDIR': tempfile.gettempdir(),
            'WEBDIR': 'htdocs',
            'LIBDIR': 'lib',
            'COMPOSER_INSTALL_OPTIONS': ['--optimize-autoloader'],
            'BP_DIR': ''
        })

        instance_stub = Dingus()
        instance_stub._set_return_value("""{"rate": {"limit": 60, "remaining": 60}}""")

        stream_output_stub = Dingus()

        rewrite_stub = Dingus()

        builder = Dingus(_ctx=ctx)

        with patches({
            'StringIO.StringIO.getvalue': instance_stub,
            'composer.extension.stream_output': stream_output_stub,
            'composer.extension.utils.rewrite_cfgs': rewrite_stub
        }):
            ct = self.extension_module.ComposerExtension(ctx)
            ct._builder = builder
            ct.composer_runner = \
                self.extension_module.ComposerCommandRunner(ctx, builder)
            ct.run()
            eq_(2, len(builder.move.calls()))
            eq_(1, len(builder.copy.calls()))
            assert rewrite_stub.calls().once()
            rewrite_args = rewrite_stub.calls()[0].args
            assert rewrite_args[0].endswith('php.ini')
            assert 'HOME' in rewrite_args[1]
            assert 'TMPDIR' in rewrite_args[1]
            instCmd = stream_output_stub.calls()[-1].args[1]
            assert instCmd.find('--optimize-autoloader') > 0
    def test_github_oauth_token_is_valid_interprets_github_api_200_as_true(self):
        ctx = utils.FormattedDict({
            'BUILD_DIR': tempfile.gettempdir(),
            'PHP_VM': 'php',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
        })

        instance_stub = Dingus()
        instance_stub._set_return_value("""{"resources": {}}""")

        stream_output_stub = Dingus('test_github_oauth_token_uses_curl : stream_output')

        with patch('StringIO.StringIO.getvalue', instance_stub):
            with patch('composer.extension.stream_output', stream_output_stub):
                ct = self.extension_module.ComposerExtension(ctx)
                result = ct._github_oauth_token_is_valid('MADE_UP_TOKEN_VALUE')

        assert result == True, '_github_oauth_token_is_valid returned %s, expected True' % result
Example #24
0
    def test_no_github_api_call_with_cached_buildpack(self):
        ctx = utils.FormattedDict({
            'BUILD_DIR': tempfile.gettempdir(),
            'PHP_VM': 'php',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
            'BP_DIR': '',
            'WEBDIR': ''
        })

        builder = Dingus(_ctx=ctx)

        path_exists_stub = Dingus()
        path_exists_stub._set_return_value(True)

        setup_composer_github_token_stub = Dingus()
        check_github_rate_exceeded_stub = Dingus()

        rewrite_stub = Dingus()

        stream_output_stub = Dingus(
            'test_github_oauth_token_uses_curl : stream_output')
        with patches({
            'os.path.exists': path_exists_stub,
            'composer.extension.ComposerExtension.setup_composer_github_token': setup_composer_github_token_stub,
            'composer.extension.ComposerExtension.check_github_rate_exceeded': check_github_rate_exceeded_stub,
            'composer.extension.utils.rewrite_cfgs': rewrite_stub,
            'composer.extension.stream_output': stream_output_stub
        }):
            ct = self.extension_module.ComposerExtension(ctx)
            ct._builder = builder
            ct.composer_runner = \
                    self.extension_module.ComposerCommandRunner(ctx, builder)
            ct.run()

        assert 0 == len(setup_composer_github_token_stub.calls()), \
                'setup_composer_github_token was called, expected no calls'
        assert 0 == len(check_github_rate_exceeded_stub.calls()), \
                'check_github_rate_exceeded was called, expected no calls'
    def test_run_does_not_set_github_oauth_if_missing(self):
        ctx = utils.FormattedDict({
            'DOWNLOAD_URL': 'http://server/bins',
            'CACHE_HASH_ALGORITHM': 'sha1',
            'BUILD_DIR': '/usr/awesome',
            'PHP_VM': 'php',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
            'BP_DIR': ''
        })
        instance_stub = Dingus()
        instance_stub._set_return_value("""{"rate": {"limit": 60, "remaining": 60}}""")

        stream_output_stub = Dingus()

        rewrite_stub = Dingus()

        builder = Dingus(_ctx=ctx)

        setup_composer_github_token_stub = Dingus()

        with patches({
            'StringIO.StringIO.getvalue': instance_stub,
            'composer.extension.stream_output': stream_output_stub,
            'composer.extension.utils.rewrite_cfgs': rewrite_stub,
            'composer.extension.ComposerExtension.setup_composer_github_token': setup_composer_github_token_stub
        }):
            ct = self.extension_module.ComposerExtension(ctx)

            ct._builder = builder
            ct.composer_runner = \
                self.extension_module.ComposerCommandRunner(ctx, builder)
            ct.run()

            setup_composer_github_token_calls = setup_composer_github_token_stub.calls()

        assert 0 == len(setup_composer_github_token_calls), \
            'setup_composer_github_token() was called %s times, expected 0' % len(setup_composer_github_token_calls)
Example #26
0
    def test_github_oauth_token_is_valid_interprets_github_api_200_as_true(
            self):
        ctx = utils.FormattedDict({
            'BUILD_DIR': tempfile.gettempdir(),
            'PHP_VM': 'php',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
        })

        instance_stub = Dingus()
        instance_stub._set_return_value("""{"resources": {}}""")

        stream_output_stub = Dingus(
            'test_github_oauth_token_uses_curl : stream_output')

        with patch('StringIO.StringIO.getvalue', instance_stub):
            with patch('composer.extension.stream_output', stream_output_stub):
                ct = self.extension_module.ComposerExtension(ctx)
                result = ct._github_oauth_token_is_valid('MADE_UP_TOKEN_VALUE')

        assert result == True, '_github_oauth_token_is_valid returned %s, expected True' % result
Example #27
0
    def test_composer_run_streams_output(self):
        ctx = utils.FormattedDict({
            'PHP_VM': 'hhvm',  # PHP strategy does other stuff
            'DOWNLOAD_URL': 'http://server/bins',
            'CACHE_HASH_ALGORITHM': 'sha1',
            'BUILD_DIR': '/build/dir',
            'CACHE_DIR': '/cache/dir',
            'TMPDIR': tempfile.gettempdir(),
            'WEBDIR': 'htdocs',
            'LIBDIR': 'lib',
            'BP_DIR': ''
        })

        instance_stub = Dingus()
        instance_stub._set_return_value(
            """{"rate": {"limit": 60, "remaining": 60}}""")

        stream_output_stub = Dingus()

        builder = Dingus(_ctx=ctx)

        with patches({
                'StringIO.StringIO.getvalue': instance_stub,
                'composer.extension.stream_output': stream_output_stub
        }):
            ct = self.extension_module.ComposerExtension(ctx)
            ct._builder = builder
            ct.composer_runner = \
                    self.extension_module.ComposerCommandRunner(ctx, builder)
            ct.run()
            stream_output_calls = stream_output_stub.calls()
            assert 2 == len(stream_output_calls), \
                    "The number of stream_output calls returned %s, expected 2" % len(stream_output_stub.calls())
            instCmd = stream_output_calls[-1].args[1]
            assert instCmd.find('/build/dir/php/bin/composer.phar') > 0
            assert instCmd.find('install') > 0
            assert instCmd.find('--no-progress') > 0
            assert instCmd.find('--no-interaction') > 0
            assert instCmd.find('--no-dev') > 0
    def test_composer_run_streams_output(self):
        ctx = utils.FormattedDict({
            'PHP_VM': 'hhvm',  # PHP strategy does other stuff
            'DOWNLOAD_URL': 'http://server/bins',
            'CACHE_HASH_ALGORITHM': 'sha1',
            'BUILD_DIR': '/build/dir',
            'CACHE_DIR': '/cache/dir',
            'TMPDIR': tempfile.gettempdir(),
            'WEBDIR': 'htdocs',
            'LIBDIR': 'lib',
            'BP_DIR': ''
        })

        instance_stub = Dingus()
        instance_stub._set_return_value("""{"rate": {"limit": 60, "remaining": 60}}""")

        stream_output_stub = Dingus()

        builder = Dingus(_ctx=ctx)

        with patches({
            'StringIO.StringIO.getvalue': instance_stub,
            'composer.extension.stream_output': stream_output_stub
        }):
            ct = self.extension_module.ComposerExtension(ctx)
            ct._builder = builder
            ct.composer_runner = \
                    self.extension_module.ComposerCommandRunner(ctx, builder)
            ct.run()
            stream_output_calls = stream_output_stub.calls()
            assert 2 == len(stream_output_calls), \
                    "The number of stream_output calls returned %s, expected 2" % len(stream_output_stub.calls())
            instCmd = stream_output_calls[-1].args[1]
            assert instCmd.find('/build/dir/php/bin/composer.phar') > 0
            assert instCmd.find('install') > 0
            assert instCmd.find('--no-progress') > 0
            assert instCmd.find('--no-interaction') > 0
            assert instCmd.find('--no-dev') > 0
Example #29
0
    def test_composer_run_streams_output(self):
        ctx = utils.FormattedDict(
            {
                "PHP_VM": "hhvm",  # PHP strategy does other stuff
                "BUILD_DIR": "/build/dir",
                "CACHE_DIR": "/cache/dir",
                "TMPDIR": tempfile.gettempdir(),
                "WEBDIR": "htdocs",
                "LIBDIR": "lib",
                "BP_DIR": "",
            }
        )

        instance_stub = Dingus()
        instance_stub._set_return_value("""{"rate": {"limit": 60, "remaining": 60}}""")

        stream_output_stub = Dingus()

        builder = Dingus(_ctx=ctx)

        with patches(
            {"StringIO.StringIO.getvalue": instance_stub, "composer.extension.stream_output": stream_output_stub}
        ):
            ct = self.extension_module.ComposerExtension(ctx)
            ct._builder = builder
            ct.composer_runner = self.extension_module.ComposerCommandRunner(ctx, builder)
            ct.run()
            stream_output_calls = stream_output_stub.calls()
            assert 2 == len(stream_output_calls), "The number of stream_output calls returned %s, expected 2" % len(
                stream_output_stub.calls()
            )
            instCmd = stream_output_calls[-1].args[1]
            assert instCmd.find("/build/dir/php/bin/composer.phar") > 0
            assert instCmd.find("install") > 0
            assert instCmd.find("--no-progress") > 0
            assert instCmd.find("--no-interaction") > 0
            assert instCmd.find("--no-dev") > 0
Example #30
0
    def test_github_download_rate_is_exceeded(self):  # noqa
        ctx = utils.FormattedDict(
            {
                "BUILD_DIR": tempfile.gettempdir(),
                "PHP_VM": "php",
                "TMPDIR": tempfile.gettempdir(),
                "LIBDIR": "lib",
                "CACHE_DIR": "cache",
                "WEBDIR": "",
            }
        )

        instance_stub = Dingus()
        instance_stub._set_return_value("""{"rate": {"limit": 60, "remaining": 0}}""")

        stream_output_stub = Dingus("test_github_oauth_token_uses_curl : stream_output")

        with patches(
            {"StringIO.StringIO.getvalue": instance_stub, "composer.extension.stream_output": stream_output_stub}
        ):
            ct = self.extension_module.ComposerExtension(ctx)
            result = ct._github_rate_exceeded(False)

        assert result is True, "_github_oauth_token_is_valid returned %s, expected True" % result
Example #31
0
    def test_github_oauth_token_is_valid_interprets_github_api_401_as_false(self):  # noqa
        ctx = utils.FormattedDict(
            {
                "BUILD_DIR": tempfile.gettempdir(),
                "PHP_VM": "php",
                "TMPDIR": tempfile.gettempdir(),
                "LIBDIR": "lib",
                "CACHE_DIR": "cache",
                "WEBDIR": "",
            }
        )

        instance_stub = Dingus()
        instance_stub._set_return_value("""{}""")

        stream_output_stub = Dingus("test_github_oauth_token_uses_curl : stream_output")

        with patches(
            {"StringIO.StringIO.getvalue": instance_stub, "composer.extension.stream_output": stream_output_stub}
        ):
            ct = self.extension_module.ComposerExtension(ctx)
            result = ct._github_oauth_token_is_valid("MADE_UP_TOKEN_VALUE")

        assert result is False, "_github_oauth_token_is_valid returned %s, expected False" % result
Example #32
0
    def test_run_sets_github_oauth_token_if_present(self):
        ctx = utils.FormattedDict({
            'DOWNLOAD_URL': 'http://server/bins',
            'CACHE_HASH_ALGORITHM': 'sha1',
            'BUILD_DIR': '/usr/awesome',
            'PHP_VM': 'php',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
            'COMPOSER_GITHUB_OAUTH_TOKEN': 'MADE_UP_TOKEN_VALUE',
            'BP_DIR': ''
        })

        instance_stub = Dingus()
        instance_stub._set_return_value(
            """{"rate": {"limit": 60, "remaining": 60}}""")

        stream_output_stub = Dingus()

        rewrite_stub = Dingus()

        environ_stub = Dingus()
        environ_stub._set_return_value('MADE_UP_TOKEN_VALUE')

        with patches({
                'StringIO.StringIO.getvalue': instance_stub,
                'composer.extension.stream_output': stream_output_stub,
                'composer.extension.utils.rewrite_cfgs': rewrite_stub,
                'os.environ.get': environ_stub
        }):
            ct = self.extension_module.ComposerExtension(ctx)

            builder_stub = Dingus(_ctx=ctx)
            ct._builder = builder_stub
            ct.composer_runner = \
                self.extension_module.ComposerCommandRunner(ctx, builder_stub)

            github_oauth_token_is_valid_stub = Dingus(
                'test_run_sets_github_oauth_token_if_present:'
                'github_oauth_token_is_valid_stub')
            github_oauth_token_is_valid_stub._set_return_value(True)
            ct._github_oauth_token_is_valid = github_oauth_token_is_valid_stub

            ct.run()

            executed_command = stream_output_stub.calls()[0].args[1]

        assert executed_command.find('config') > 0, 'did not see "config"'
        assert executed_command.find('-g') > 0, 'did not see "-g"'
        assert executed_command.find('github-oauth.github.com') > 0, \
            'did not see "github-oauth.github.com"'
        assert executed_command.find('"MADE_UP_TOKEN_VALUE"') > 0, \
            'did not see "MADE_UP_TOKEN_VALUE"'
    def test_run_sets_github_oauth_token_if_present(self):
        ctx = utils.FormattedDict({
            'DOWNLOAD_URL': 'http://server/bins',
            'CACHE_HASH_ALGORITHM': 'sha1',
            'BUILD_DIR': '/usr/awesome',
            'PHP_VM': 'php',
            'TMPDIR': tempfile.gettempdir(),
            'LIBDIR': 'lib',
            'CACHE_DIR': 'cache',
            'COMPOSER_GITHUB_OAUTH_TOKEN': 'MADE_UP_TOKEN_VALUE',
            'BP_DIR': ''
        })

        instance_stub = Dingus()
        instance_stub._set_return_value("""{"rate": {"limit": 60, "remaining": 60}}""")

        stream_output_stub = Dingus()

        rewrite_stub = Dingus()

        environ_stub = Dingus()
        environ_stub._set_return_value('MADE_UP_TOKEN_VALUE')

        with patches({
            'StringIO.StringIO.getvalue': instance_stub,
            'composer.extension.stream_output': stream_output_stub,
            'composer.extension.utils.rewrite_cfgs': rewrite_stub,
            'os.environ.get': environ_stub
        }):
            ct = self.extension_module.ComposerExtension(ctx)

            builder_stub = Dingus(_ctx=ctx)
            ct._builder = builder_stub
            ct.composer_runner = \
                self.extension_module.ComposerCommandRunner(ctx, builder_stub)

            github_oauth_token_is_valid_stub = Dingus(
                'test_run_sets_github_oauth_token_if_present:'
                'github_oauth_token_is_valid_stub')
            github_oauth_token_is_valid_stub._set_return_value(True)
            ct._github_oauth_token_is_valid = github_oauth_token_is_valid_stub

            ct.run()

            executed_command = stream_output_stub.calls()[0].args[1]

        assert executed_command.find('config') > 0, 'did not see "config"'
        assert executed_command.find('-g') > 0, 'did not see "-g"'
        assert executed_command.find('github-oauth.github.com') > 0, \
            'did not see "github-oauth.github.com"'
        assert executed_command.find('"MADE_UP_TOKEN_VALUE"') > 0, \
            'did not see "MADE_UP_TOKEN_VALUE"'
Example #34
0
    def test_run_sets_github_oauth_token_if_present(self):
        ctx = utils.FormattedDict(
            {
                "BUILD_DIR": "/usr/awesome",
                "PHP_VM": "php",
                "TMPDIR": tempfile.gettempdir(),
                "LIBDIR": "lib",
                "CACHE_DIR": "cache",
                "COMPOSER_GITHUB_OAUTH_TOKEN": "MADE_UP_TOKEN_VALUE",
                "BP_DIR": "",
                "WEBDIR": "",
            }
        )

        instance_stub = Dingus()
        instance_stub._set_return_value("""{"rate": {"limit": 60, "remaining": 60}}""")

        stream_output_stub = Dingus()

        rewrite_stub = Dingus()

        environ_stub = Dingus()
        environ_stub._set_return_value("MADE_UP_TOKEN_VALUE")

        with patches(
            {
                "StringIO.StringIO.getvalue": instance_stub,
                "composer.extension.stream_output": stream_output_stub,
                "composer.extension.utils.rewrite_cfgs": rewrite_stub,
                "os.environ.get": environ_stub,
            }
        ):
            ct = self.extension_module.ComposerExtension(ctx)

            builder_stub = Dingus(_ctx=ctx)
            ct._builder = builder_stub
            ct.composer_runner = self.extension_module.ComposerCommandRunner(ctx, builder_stub)

            github_oauth_token_is_valid_stub = Dingus(
                "test_run_sets_github_oauth_token_if_present:" "github_oauth_token_is_valid_stub"
            )
            github_oauth_token_is_valid_stub._set_return_value(True)
            ct._github_oauth_token_is_valid = github_oauth_token_is_valid_stub

            ct.run()

            executed_command = stream_output_stub.calls()[0].args[1]

        assert executed_command.find("config") > 0, 'did not see "config"'
        assert executed_command.find("-g") > 0, 'did not see "-g"'
        assert executed_command.find("github-oauth.github.com") > 0, 'did not see "github-oauth.github.com"'
        assert executed_command.find('"MADE_UP_TOKEN_VALUE"') > 0, 'did not see "MADE_UP_TOKEN_VALUE"'