def testDisplayConfig(self):
        handle = self.getRbuildHandle(mockOutput=False)
        _, txt = self.captureOutput(handle.Config.displayConfig)
        expectedText = '''\
contact                   http://bugzilla.rpath.com/
name                      Test
pluginDirs                %s
quiet                     False
repositoryMap             []
rmakePluginDirs           %s
serverUrl                 some non-empty value
signatureKeyMap           []
user                      test <password>
''' % (resources.get_plugin_dirs()[0], rmake_resources.get_plugin_dirs()[0])
        self.assertEqualsText(txt, expectedText)

        _, txt = self.captureOutput(handle.Config.displayConfig, 
                                    hidePasswords=False)
        expectedPasswordText = '''\
contact                   http://bugzilla.rpath.com/
name                      Test
pluginDirs                %s
quiet                     False
repositoryMap             []
rmakePluginDirs           %s
serverUrl                 some non-empty value
signatureKeyMap           []
user                      test foo
''' % (resources.get_plugin_dirs()[0], rmake_resources.get_plugin_dirs()[0])
        self.assertEqualsText(txt, expectedPasswordText)
Beispiel #2
0
    def testDisplayConfig(self):
        handle = self.getRbuildHandle(mockOutput=False)
        _, txt = self.captureOutput(handle.Config.displayConfig)
        expectedText = '''\
contact                   http://bugzilla.rpath.com/
name                      Test
pluginDirs                %s
quiet                     False
repositoryMap             []
repositoryUser            []
rmakePluginDirs           %s
serverUrl                 some non-empty value
signatureKeyMap           []
user                      test <password>
''' % (resources.get_plugin_dirs()[0], rmake_resources.get_plugin_dirs()[0])
        self.assertEqualsText(txt, expectedText)

        _, txt = self.captureOutput(handle.Config.displayConfig,
                                    hidePasswords=False)
        expectedPasswordText = '''\
contact                   http://bugzilla.rpath.com/
name                      Test
pluginDirs                %s
quiet                     False
repositoryMap             []
repositoryUser            []
rmakePluginDirs           %s
serverUrl                 some non-empty value
signatureKeyMap           []
user                      test foo
''' % (resources.get_plugin_dirs()[0], rmake_resources.get_plugin_dirs()[0])
        self.assertEqualsText(txt, expectedPasswordText)
Beispiel #3
0
    def testDisplayConfig(self):
        handle = self.getRbuildHandle(mockOutput=False)
        _, txt = self.captureOutput(handle.Config.displayConfig)
        expectedText = '''\
applianceTemplate         groupSetAppliance
contact                   http://bugzilla.rpath.com/
factoryTemplate           factory
groupTemplate             groupSet
name                      Test
pluginDirs                %s
quiet                     False
recipeTemplate            default
recipeTemplateDirs        %s:~/.conary/recipeTemplates:/etc/conary/recipeTemplates
repositoryMap             []
repositoryUser            []
rmakePluginDirs           %s
serverUrl                 http://example.com
signatureKeyMap           []
user                      test <password>
''' % (resources.get_plugin_dirs()[0],
        resources.get_test_path('config', 'recipeTemplates'),
        rmake_resources.get_plugin_dirs()[0])
        self.assertEqualsText(txt, expectedText)

        _, txt = self.captureOutput(handle.Config.displayConfig,
                                    hidePasswords=False)
        expectedPasswordText = '''\
applianceTemplate         groupSetAppliance
contact                   http://bugzilla.rpath.com/
factoryTemplate           factory
groupTemplate             groupSet
name                      Test
pluginDirs                %s
quiet                     False
recipeTemplate            default
recipeTemplateDirs        %s:~/.conary/recipeTemplates:/etc/conary/recipeTemplates
repositoryMap             []
repositoryUser            []
rmakePluginDirs           %s
serverUrl                 http://example.com
signatureKeyMap           []
user                      test foo
''' % (resources.get_plugin_dirs()[0],
        resources.get_test_path('config', 'recipeTemplates'),
        rmake_resources.get_plugin_dirs()[0])
        self.assertEqualsText(txt, expectedPasswordText)
    def testUpdateConfig(self):
        homeDir = self.workDir + '/home'
        os.mkdir(homeDir)
        oldHome = os.environ['HOME']
        try:
            os.environ['HOME'] = homeDir
            handle = self.getRbuildHandle(productStore=mock.MockObject(),
                                          mockOutput=False)
            cfg = handle._cfg
            cfg.user = None
            cfg.rmakeUrl = 'https://localhost:9999'
            m = mock.mockMethod(handle.ui.input)

            m._mock.setDefaultReturns(['http://localhost/',
                                       'testuser', 'N', 'N', 'Contact',
                                       'Display Name'])
            m = mock.mockMethod(handle.ui.inputPassword)
            m._mock.setDefaultReturns(['testpass'])
            mock.mockMethod(handle.facade.rbuilder.validateUrl)._mock.setReturn(True)
            mock.mockMethod(handle.facade.rbuilder.checkForRmake)._mock.setReturn(True)
            mock.mockMethod(handle.facade.rbuilder.validateRbuilderUrl)._mock.setReturn(True)
            mock.mockMethod(handle.facade.rbuilder.validateCredentials)._mock.setReturn(
                {'authorized':True})
            mock.mockMethod(handle.facade.conary._parseRBuilderConfigFile)
            rc, txt = self.captureOutput(handle.Config.updateConfig)
            self.assertEquals(txt, 'rBuilder contacted successfully.\nrBuilder authorized successfully.\n')
            txt = open(self.workDir + '/home/.rbuildrc').read()
            expectedText = '''\
# This file will be overwritten by the "rbuild config --ask" command
# contact (Default: None)
contact                   Display Name
# name (Default: None)
name                      Contact
# pluginDirs (Default: /usr/share/rbuild/plugins:~/.rbuild/plugins.d)
pluginDirs                %s
# quiet (Default: False)
quiet                     False
# repositoryMap (Default: [])
repositoryMap             []
# rmakePluginDirs (Default: /usr/share/rmake/plugins:~/.rmake/plugins.d)
rmakePluginDirs           %s
# rmakeUrl (Default: None)
rmakeUrl                  https://localhost:9999
# rmakeUser (Default: None)
# serverUrl (Default: None)
serverUrl                 http://localhost
# signatureKey (Default: None)
# signatureKeyMap (Default: [])
signatureKeyMap           []
# user (Default: None)
user                      testuser
''' % (resources.get_plugin_dirs()[0], rmake_resources.get_plugin_dirs()[0])
            self.assertEqualsText(txt, expectedText)

        finally:
            os.environ['HOME'] = oldHome
Beispiel #5
0
 def setUp(self):
     rmakehelp.RmakeHelper.setUp(self)
     self.rbuildCfg = rbuildcfg.RbuildConfiguration(readConfigFiles=False,
             root=self.cfg.root)
     self.rbuildCfg.contact = self.cfg.contact
     self.rbuildCfg.name = self.cfg.name
     self.rbuildCfg.pluginDirs = resources.get_plugin_dirs()
     self.rbuildCfg.serverUrl = 'some non-empty value'
     self.rbuildCfg.rmakePluginDirs = rmake_resources.get_plugin_dirs()
     self.writeFile(self.cfg.root + '/conaryrc', '')
     self.rbuildCfg.user = ('test', 'foo')
     self.setUpSchemaDir()
Beispiel #6
0
 def setUp(self):
     rmakehelp.RmakeHelper.setUp(self)
     self.rbuildCfg = rbuildcfg.RbuildConfiguration(readConfigFiles=False,
                                                    root=self.cfg.root)
     self.rbuildCfg.contact = self.cfg.contact
     self.rbuildCfg.name = self.cfg.name
     self.rbuildCfg.pluginDirs = resources.get_plugin_dirs()
     self.rbuildCfg.serverUrl = 'some non-empty value'
     self.rbuildCfg.rmakePluginDirs = rmake_resources.get_plugin_dirs()
     self.writeFile(self.cfg.root + '/conaryrc', '')
     self.rbuildCfg.user = ('test', 'foo')
     self.setUpSchemaDir()
Beispiel #7
0
 def setUp(self):
     rmakehelp.RmakeHelper.setUp(self)
     self.rbuildCfg = rbuildcfg.RbuildConfiguration(readConfigFiles=False,
             root=self.cfg.root)
     self.rbuildCfg.contact = self.cfg.contact
     self.rbuildCfg.name = self.cfg.name
     self.rbuildCfg.pluginDirs = resources.get_plugin_dirs()
     self.rbuildCfg.serverUrl = 'http://example.com'
     self.rbuildCfg.rmakePluginDirs = rmake_resources.get_plugin_dirs()
     self.writeFile(self.cfg.root + '/conaryrc', '')
     self.rbuildCfg.user = ('test', 'foo')
     self.rbuildCfg.recipeTemplateDirs.insert(0,
             resources.get_test_path('config', 'recipeTemplates'))
     self.setUpSchemaDir()
    def testInitializeConfigNoPassword(self):
        homeDir = self.workDir + '/home'
        os.mkdir(homeDir)
        oldHome = os.environ['HOME']
        try:
            os.environ['HOME'] = homeDir
            handle = self.getRbuildHandle(productStore=mock.MockObject(),
                                          mockOutput=False)
            m1 = mock.mockMethod(handle.ui.input)
            m1._mock.setDefaultReturns([
                'http://localhost',
               'testuser',
               # (password func is mocked)
               'Y', # Use same URL for rmake
               'N', # Save password in config file
               'Contact',
               'Display Name',
               ])
            m1._mock.setFailOnMismatch()
            m2 = mock.mockMethod(handle.ui.inputPassword)
            m2._mock.setDefaultReturns(['testpass','last'])
            m2._mock.setFailOnMismatch()
            mock.mockMethod(handle.facade.rbuilder.validateUrl) \
                ._mock.setReturn(True)
            mock.mockMethod(handle.facade.rbuilder.validateRbuilderUrl) \
                ._mock.setReturn(True)
            mock.mockMethod(handle.facade.rbuilder.validateCredentials) \
                ._mock.setReturn({'authorized':True})
            mock.mockMethod(handle.facade.rbuilder.checkForRmake)._mock.setReturn(True)
            mock.mockMethod(handle.facade.conary._parseRBuilderConfigFile)

            rc, txt = self.captureOutput(handle.Config.initializeConfig)

            # make sure all of our mock retruns were consumed correctly
            self.assertEquals(len(m1._mock.calls), 6)
            self.assertEquals(len(m2._mock.calls), 1)
            expectedUnconfiguredTxt = '''\
********************************************************
Welcome to rBuild!  Your configuration is incomplete.
Please answer the following questions to begin using rBuild:

rBuilder contacted successfully.
rBuilder authorized successfully.
rBuild configuration complete.  To rerun this configuration test run rbuild config --ask, or simply edit ~/.rbuildrc.

You should now begin working with a product by running 'rbuild init <short name> <version>'
'''
            self.assertEqualsText(txt, expectedUnconfiguredTxt)
            txt = open(self.workDir + '/home/.rbuildrc').read()
            expectedConfiguredTxt = '''\
# This file will be overwritten by the "rbuild config --ask" command
# contact (Default: None)
contact                   Display Name
# name (Default: None)
name                      Contact
# pluginDirs (Default: /usr/share/rbuild/plugins:~/.rbuild/plugins.d)
pluginDirs                %s
# quiet (Default: False)
quiet                     False
# repositoryMap (Default: [])
repositoryMap             []
# rmakePluginDirs (Default: /usr/share/rmake/plugins:~/.rmake/plugins.d)
rmakePluginDirs           %s
# rmakeUrl (Default: None)
rmakeUrl                  https://localhost:9999
# rmakeUser (Default: None)
# serverUrl (Default: None)
serverUrl                 http://localhost
# signatureKey (Default: None)
# signatureKeyMap (Default: [])
signatureKeyMap           []
# user (Default: None)
user                      testuser
''' % (resources.get_plugin_dirs()[0], rmake_resources.get_plugin_dirs()[0])
            self.assertEqualsText(txt, expectedConfiguredTxt)
            #Test to see that the permissions are set correctly
            self.assertEquals(os.stat(self.workDir + '/home/.rbuildrc').st_mode & 0777, 0600)

            # Now test contents of synced conary/rmake config files
            expectedTxt = '''\
# Include config file maintained by rBuild:
includeConfigFile ~/.conaryrc-rbuild
'''
            txt = open(self.workDir + '/home/.conaryrc').read()
            self.assertEqualsText(txt, expectedTxt)
            self.assertEquals(os.stat(self.workDir + '/home/.conaryrc').st_mode & 0777, 0600)

            expectedTxt = '''\
# Include config file maintained by rBuild:
includeConfigFile ~/.rmakerc-rbuild
'''
            txt = open(self.workDir + '/home/.rmakerc').read()
            self.assertEqualsText(txt, expectedTxt)
            self.assertEquals(os.stat(self.workDir + '/home/.rmakerc').st_mode & 0777, 0600)

            expectedTxt = '''\
# This file will be overwritten automatically by rBuild
# You can ignore it by removing the associated includeConfigFile
# line from ~/.conaryrc
# contact (Default: None)
contact                   Display Name
# name (Default: None)
name                      Contact
# repositoryMap (Default: [])
repositoryMap             []
# user (Default: [])
user                      * testuser 
'''
            txt = open(self.workDir + '/home/.conaryrc-rbuild').read()
            self.assertEqualsText(txt, expectedTxt)
            self.assertEquals(os.stat(self.workDir + '/home/.conaryrc-rbuild').st_mode & 0777, 0600)

            expectedTxt = '''\
# This file will be overwritten automatically by rBuild.
# You can ignore it by removing the associated includeConfigFile
# line from ~/.rmakerc
# rbuilderUrl (Default: https://localhost/)
rbuilderUrl               http://localhost
# rmakeUrl (Default: unix:///var/lib/rmake/socket)
rmakeUrl                  https://localhost:9999
# rmakeUser (Default: None)
rmakeUser                 testuser 
'''
            txt = open(self.workDir + '/home/.rmakerc-rbuild').read()
            self.assertEqualsText(txt, expectedTxt)
            self.assertEquals(os.stat(self.workDir + '/home/.rmakerc-rbuild').st_mode & 0777, 0600)
        finally:
            os.environ['HOME'] = oldHome
    def testInitializeConfigFromExistingData(self):
        homeDir = self.workDir + '/home'
        os.mkdir(homeDir)
        oldHome = os.environ['HOME']
        self.rbuildCfg.user = None
        self.rbuildCfg.contact = None
        self.rbuildCfg.name = None
        self.rbuildCfg.serverUrl = None
        try:
            os.environ['HOME'] = homeDir
            handle = self.getRbuildHandle(productStore=mock.MockObject(),
                                          mockOutput=False)
            m = mock.mockMethod(handle.ui.input)
            m._mock.setDefaultReturns(['', '', '', ''])
            m = mock.mockMethod(handle.ui.inputPassword)
            m._mock.setDefaultReturns([''])
            mock.mockMethod(handle.facade.rbuilder.validateUrl)._mock.setReturn(True)
            mock.mockMethod(handle.facade.rbuilder.validateRbuilderUrl)._mock.setReturn(True)
            mock.mockMethod(handle.facade.rbuilder.validateCredentials)._mock.setReturn(
                {'authorized':True})
            mock.mockMethod(handle.facade.conary._parseRBuilderConfigFile)

            # provide existing data
            mock.mockMethod(handle.facade.rbuilder._getBaseServerUrlData)._mock.setReturn(('http://localhost', 'testuser', 'testpass'))
            mockccfg = mock.MockObject()
            mockccfg._mock.enable('name')
            mockccfg.name = 'Display Name'
            mockccfg._mock.enable('contact')
            mockccfg.contact = 'Contact'
            mock.mockMethod(handle.facade.conary._getBaseConaryConfig)._mock.setReturn(mockccfg)
            mockrcfg = mock.MockObject()
            mockrcfg._mock.enable('rmakeUrl')
            mockrcfg.rmakeUrl = 'https://localhost:9999'
            mockrcfg._mock.enable('rmakeUser')
            mockrcfg.rmakeUser = ('user1', 'password1')
            mock.mockMethod(handle.facade.rmake._getBaseRmakeConfig)._mock.setReturn(mockrcfg)

            rc, txt = self.captureOutput(handle.Config.initializeConfig)
            expectedUnconfiguredTxt = '''\
********************************************************
Welcome to rBuild!  Your configuration is incomplete.
Please answer the following questions to begin using rBuild:

rBuilder contacted successfully.
rBuilder authorized successfully.
rBuild configuration complete.  To rerun this configuration test run rbuild config --ask, or simply edit ~/.rbuildrc.

You should now begin working with a product by running 'rbuild init <short name> <version>'
'''
            self.assertEqualsText(txt, expectedUnconfiguredTxt)
            txt = open(self.workDir + '/home/.rbuildrc').read()
            expectedConfiguredTxt = '''\
# This file will be overwritten by the "rbuild config --ask" command
# contact (Default: None)
contact                   Contact
# name (Default: None)
name                      Display Name
# pluginDirs (Default: /usr/share/rbuild/plugins:~/.rbuild/plugins.d)
pluginDirs                %s
# quiet (Default: False)
quiet                     False
# repositoryMap (Default: [])
repositoryMap             []
# rmakePluginDirs (Default: /usr/share/rmake/plugins:~/.rmake/plugins.d)
rmakePluginDirs           %s
# rmakeUrl (Default: None)
rmakeUrl                  https://localhost:9999
# rmakeUser (Default: None)
# serverUrl (Default: None)
serverUrl                 http://localhost
# signatureKey (Default: None)
# signatureKeyMap (Default: [])
signatureKeyMap           []
# user (Default: None)
user                      testuser
''' % (resources.get_plugin_dirs()[0], rmake_resources.get_plugin_dirs()[0])
            self.assertEqualsText(txt, expectedConfiguredTxt)
            #Test to see that the permissions are set correctly
            self.assertEquals(os.stat(self.workDir + '/home/.rbuildrc').st_mode & 0777, 0600)
        finally:
            os.environ['HOME'] = oldHome
Beispiel #10
0
    def testInitializeConfigNoPassword(self):
        homeDir = self.workDir + '/home'
        os.mkdir(homeDir)
        oldHome = os.environ['HOME']
        try:
            os.environ['HOME'] = homeDir
            handle = self.getRbuildHandle(productStore=mock.MockObject(),
                                          mockOutput=False)
            m1 = mock.mockMethod(handle.ui.input)
            m1._mock.setDefaultReturns([
                'http://localhost',
                'testuser',
                # (password func is mocked)
                'Y',  # Use same URL for rmake
                'N',  # Save password in config file
                'Contact',
                'Display Name',
            ])
            m1._mock.setFailOnMismatch()
            m2 = mock.mockMethod(handle.ui.inputPassword)
            m2._mock.setDefaultReturns(['testpass', 'last'])
            m2._mock.setFailOnMismatch()
            mock.mockMethod(handle.facade.rbuilder.validateUrl) \
                ._mock.setReturn(True)
            mock.mockMethod(handle.facade.rbuilder.validateRbuilderUrl) \
                ._mock.setReturn(True)
            mock.mockMethod(handle.facade.rbuilder.validateCredentials) \
                ._mock.setReturn({'authorized':True})
            mock.mockMethod(
                handle.facade.rbuilder.checkForRmake)._mock.setReturn(True)
            mock.mockMethod(handle.facade.conary._parseRBuilderConfigFile)

            rc, txt = self.captureOutput(handle.Config.initializeConfig)

            # make sure all of our mock retruns were consumed correctly
            self.assertEquals(len(m1._mock.calls), 6)
            self.assertEquals(len(m2._mock.calls), 1)
            expectedUnconfiguredTxt = '''\
********************************************************
Welcome to rBuild!  Your configuration is incomplete.
Please answer the following questions to begin using rBuild:

rBuilder contacted successfully.
rBuilder authorized successfully.
rBuild configuration complete.  To rerun this configuration test run rbuild config --ask, or simply edit ~/.rbuildrc.

You should now begin working with a product by running 'rbuild init <short name> <version>'
'''
            self.assertEqualsText(txt, expectedUnconfiguredTxt)
            txt = open(self.workDir + '/home/.rbuildrc').read()
            expectedConfiguredTxt = '''\
# This file will be overwritten by the "rbuild config --ask" command
# contact (Default: None)
contact                   Display Name
# name (Default: None)
name                      Contact
# pluginDirs (Default: /usr/share/rbuild/plugins:~/.rbuild/plugins.d)
pluginDirs                %s
# quiet (Default: False)
quiet                     False
# repositoryMap (Default: [])
repositoryMap             []
# repositoryUser (Default: [])
repositoryUser            []
# rmakePluginDirs (Default: /usr/share/rmake/plugins:~/.rmake/plugins.d)
rmakePluginDirs           %s
# rmakeUrl (Default: None)
rmakeUrl                  https://localhost:9999
# rmakeUser (Default: None)
# serverUrl (Default: None)
serverUrl                 http://localhost
# signatureKey (Default: None)
# signatureKeyMap (Default: [])
signatureKeyMap           []
# user (Default: None)
user                      testuser
''' % (resources.get_plugin_dirs()[0], rmake_resources.get_plugin_dirs()[0])
            self.assertEqualsText(txt, expectedConfiguredTxt)
            #Test to see that the permissions are set correctly
            self.assertEquals(
                os.stat(self.workDir + '/home/.rbuildrc').st_mode & 0777, 0600)

            # Now test contents of synced conary/rmake config files
            expectedTxt = '''\
# Include config file maintained by rBuild:
includeConfigFile ~/.conaryrc-rbuild
'''
            txt = open(self.workDir + '/home/.conaryrc').read()
            self.assertEqualsText(txt, expectedTxt)
            self.assertEquals(
                os.stat(self.workDir + '/home/.conaryrc').st_mode & 0777, 0600)

            expectedTxt = '''\
# Include config file maintained by rBuild:
includeConfigFile ~/.rmakerc-rbuild
'''
            txt = open(self.workDir + '/home/.rmakerc').read()
            self.assertEqualsText(txt, expectedTxt)
            self.assertEquals(
                os.stat(self.workDir + '/home/.rmakerc').st_mode & 0777, 0600)

            expectedTxt = '''\
# This file will be overwritten automatically by rBuild
# You can ignore it by removing the associated includeConfigFile
# line from ~/.conaryrc
# contact (Default: None)
contact                   Display Name
# name (Default: None)
name                      Contact
# repositoryMap (Default: [])
repositoryMap             []
# user (Default: [])
user                      * testuser 
'''
            txt = open(self.workDir + '/home/.conaryrc-rbuild').read()
            self.assertEqualsText(txt, expectedTxt)
            self.assertEquals(
                os.stat(self.workDir + '/home/.conaryrc-rbuild').st_mode
                & 0777, 0600)

            expectedTxt = '''\
# This file will be overwritten automatically by rBuild.
# You can ignore it by removing the associated includeConfigFile
# line from ~/.rmakerc
# rbuilderUrl (Default: https://localhost/)
rbuilderUrl               http://localhost
# rmakeUrl (Default: unix:///var/lib/rmake/socket)
rmakeUrl                  https://localhost:9999
# rmakeUser (Default: None)
rmakeUser                 testuser 
'''
            txt = open(self.workDir + '/home/.rmakerc-rbuild').read()
            self.assertEqualsText(txt, expectedTxt)
            self.assertEquals(
                os.stat(self.workDir + '/home/.rmakerc-rbuild').st_mode & 0777,
                0600)
        finally:
            os.environ['HOME'] = oldHome
Beispiel #11
0
    def testUpdateConfigRmakeUrl(self):
        homeDir = self.workDir + '/home'
        os.mkdir(homeDir)
        oldHome = os.environ['HOME']
        try:
            os.environ['HOME'] = homeDir
            handle = self.getRbuildHandle(productStore=mock.MockObject(),
                                          mockOutput=False)
            cfg = handle._cfg
            cfg.user = None
            m = mock.mockMethod(handle.ui.input)
            m._mock.setDefaultReturns([
                'http://localhost/', 'testuser', 'Y', 'N', 'Contact',
                'Display Name'
            ])
            m = mock.mockMethod(handle.ui.inputPassword)
            m._mock.setDefaultReturns(['testpass'])
            mock.mockMethod(
                handle.facade.rbuilder.validateUrl)._mock.setReturn(True)
            mock.mockMethod(
                handle.facade.rbuilder.checkForRmake)._mock.setDefaultReturn(
                    True)
            mock.mockMethod(
                handle.facade.rbuilder.validateRbuilderUrl)._mock.setReturn(
                    True)
            mock.mockMethod(
                handle.facade.rbuilder.validateCredentials)._mock.setReturn(
                    {'authorized': True})
            mock.mockMethod(handle.facade.conary._parseRBuilderConfigFile)
            rc, txt = self.captureOutput(handle.Config.updateConfig)
            self.assertEquals(
                txt,
                'rBuilder contacted successfully.\nrBuilder authorized successfully.\n'
            )
            txt = open(self.workDir + '/home/.rbuildrc').read()
            expectedText = '''\
# This file will be overwritten by the "rbuild config --ask" command
# contact (Default: None)
contact                   Display Name
# name (Default: None)
name                      Contact
# pluginDirs (Default: /usr/share/rbuild/plugins:~/.rbuild/plugins.d)
pluginDirs                %s
# quiet (Default: False)
quiet                     False
# repositoryMap (Default: [])
repositoryMap             []
# repositoryUser (Default: [])
repositoryUser            []
# rmakePluginDirs (Default: /usr/share/rmake/plugins:~/.rmake/plugins.d)
rmakePluginDirs           %s
# rmakeUrl (Default: None)
rmakeUrl                  https://localhost:9999
# rmakeUser (Default: None)
# serverUrl (Default: None)
serverUrl                 http://localhost
# signatureKey (Default: None)
# signatureKeyMap (Default: [])
signatureKeyMap           []
# user (Default: None)
user                      testuser
''' % (resources.get_plugin_dirs()[0], rmake_resources.get_plugin_dirs()[0])

            self.assertEqualsText(txt, expectedText)

        finally:
            os.environ['HOME'] = oldHome
Beispiel #12
0
    def testInitializeConfigFromExistingData(self):
        homeDir = self.workDir + '/home'
        os.mkdir(homeDir)
        oldHome = os.environ['HOME']
        self.rbuildCfg.user = None
        self.rbuildCfg.contact = None
        self.rbuildCfg.name = None
        self.rbuildCfg.serverUrl = None
        try:
            os.environ['HOME'] = homeDir
            handle = self.getRbuildHandle(productStore=mock.MockObject(),
                                          mockOutput=False)
            m = mock.mockMethod(handle.ui.input)
            m._mock.setDefaultReturns(['', '', '', ''])
            m = mock.mockMethod(handle.ui.inputPassword)
            m._mock.setDefaultReturns([''])
            mock.mockMethod(
                handle.facade.rbuilder.validateUrl)._mock.setReturn(True)
            mock.mockMethod(
                handle.facade.rbuilder.validateRbuilderUrl)._mock.setReturn(
                    True)
            mock.mockMethod(
                handle.facade.rbuilder.validateCredentials)._mock.setReturn(
                    {'authorized': True})
            mock.mockMethod(handle.facade.conary._parseRBuilderConfigFile)

            # provide existing data
            mock.mockMethod(
                handle.facade.rbuilder._getBaseServerUrlData)._mock.setReturn(
                    ('http://localhost', 'testuser', 'testpass'))
            mockccfg = mock.MockObject()
            mockccfg._mock.enable('name')
            mockccfg.name = 'Display Name'
            mockccfg._mock.enable('contact')
            mockccfg.contact = 'Contact'
            mock.mockMethod(
                handle.facade.conary._getBaseConaryConfig)._mock.setReturn(
                    mockccfg)
            mockrcfg = mock.MockObject()
            mockrcfg._mock.enable('rmakeUrl')
            mockrcfg.rmakeUrl = 'https://localhost:9999'
            mockrcfg._mock.enable('rmakeUser')
            mockrcfg.rmakeUser = ('user1', 'password1')
            mock.mockMethod(
                handle.facade.rmake._getBaseRmakeConfig)._mock.setReturn(
                    mockrcfg)

            rc, txt = self.captureOutput(handle.Config.initializeConfig)
            expectedUnconfiguredTxt = '''\
********************************************************
Welcome to rBuild!  Your configuration is incomplete.
Please answer the following questions to begin using rBuild:

rBuilder contacted successfully.
rBuilder authorized successfully.
rBuild configuration complete.  To rerun this configuration test run rbuild config --ask, or simply edit ~/.rbuildrc.

You should now begin working with a product by running 'rbuild init <short name> <version>'
'''
            self.assertEqualsText(txt, expectedUnconfiguredTxt)
            txt = open(self.workDir + '/home/.rbuildrc').read()
            expectedConfiguredTxt = '''\
# This file will be overwritten by the "rbuild config --ask" command
# contact (Default: None)
contact                   Contact
# name (Default: None)
name                      Display Name
# pluginDirs (Default: /usr/share/rbuild/plugins:~/.rbuild/plugins.d)
pluginDirs                %s
# quiet (Default: False)
quiet                     False
# repositoryMap (Default: [])
repositoryMap             []
# repositoryUser (Default: [])
repositoryUser            []
# rmakePluginDirs (Default: /usr/share/rmake/plugins:~/.rmake/plugins.d)
rmakePluginDirs           %s
# rmakeUrl (Default: None)
rmakeUrl                  https://localhost:9999
# rmakeUser (Default: None)
# serverUrl (Default: None)
serverUrl                 http://localhost
# signatureKey (Default: None)
# signatureKeyMap (Default: [])
signatureKeyMap           []
# user (Default: None)
user                      testuser
''' % (resources.get_plugin_dirs()[0], rmake_resources.get_plugin_dirs()[0])
            self.assertEqualsText(txt, expectedConfiguredTxt)
            #Test to see that the permissions are set correctly
            self.assertEquals(
                os.stat(self.workDir + '/home/.rbuildrc').st_mode & 0777, 0600)
        finally:
            os.environ['HOME'] = oldHome
Beispiel #13
0
 def getCoverageDirs(self, *_):
     import rbuild
     return [rbuild] + resources.get_plugin_dirs()
Beispiel #14
0
 def getCoverageDirs(self, *_):
     import rbuild
     return [ rbuild ] + resources.get_plugin_dirs()