Skip to content

Commit

Permalink
Merge santegoeds/buildbot:support-empty-password-svnpoller (PR #1122)
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Apr 5, 2014
2 parents 3496283 + 820201b commit 2d4cbba
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 14 deletions.
12 changes: 6 additions & 6 deletions master/buildbot/changes/svnpoller.py
Expand Up @@ -57,7 +57,7 @@ def split_file_branches(path):

def split_file_projects_branches(path):
# turn projectname/trunk/subdir/file.c into dict(project=projectname, branch=trunk, path=subdir/file.c)
if not "/" in path:
if "/" not in path:
return None
project, path = path.split("/", 1)
f = split_file_branches(path)
Expand Down Expand Up @@ -108,8 +108,8 @@ def __init__(self, svnurl, split_file=None,

self.revlinktmpl = revlinktmpl

self.environ = os.environ.copy() # include environment variables
# required for ssh-agent auth
# include environment variables required for ssh-agent auth
self.environ = os.environ.copy()

self.svnbin = svnbin
self.histmax = histmax
Expand Down Expand Up @@ -198,7 +198,7 @@ def get_prefix(self):
args = ["info", "--xml", "--non-interactive", self.svnurl]
if self.svnuser:
args.append("--username=%s" % self.svnuser)
if self.svnpasswd:
if self.svnpasswd is not None:
args.append("--password=%s" % self.svnpasswd)
if self.extra_args:
args.extend(self.extra_args)
Expand Down Expand Up @@ -239,7 +239,7 @@ def get_logs(self, _):
args.extend(["log", "--xml", "--verbose", "--non-interactive"])
if self.svnuser:
args.extend(["--username=%s" % self.svnuser])
if self.svnpasswd:
if self.svnpasswd is not None:
args.extend(["--password=%s" % self.svnpasswd])
if self.extra_args:
args.extend(self.extra_args)
Expand Down Expand Up @@ -361,7 +361,7 @@ def create_changes(self, new_logentries):
if where:
branch = where.get("branch", None)
filename = where["path"]
if not branch in branches:
if branch not in branches:
branches[branch] = {'files': [], 'number_of_directories': 0}
if filename == "":
# root directory of branch
Expand Down
48 changes: 40 additions & 8 deletions master/buildbot/test/unit/test_changes_svnpoller.py
Expand Up @@ -381,14 +381,20 @@ def test_create_changes(self):
self.failUnlessEqual(changes[0]['revision'], '6')
self.failUnlessEqual(changes[0]['files'], ["version.c"])

def makeInfoExpect(self):
return gpo.Expect('svn', 'info', '--xml', '--non-interactive', sample_base,
'--username=dustin', '--password=bbrocks')

def makeLogExpect(self):
return gpo.Expect('svn', 'log', '--xml', '--verbose', '--non-interactive',
'--username=dustin', '--password=bbrocks',
'--limit=100', sample_base)
def makeInfoExpect(self, password='bbrocks'):
args = ['svn', 'info', '--xml', '--non-interactive', sample_base,
'--username=dustin']
if password is not None:
args.append('--password=' + password)
return gpo.Expect(*args)

def makeLogExpect(self, password='bbrocks'):
args = ['svn', 'log', '--xml', '--verbose', '--non-interactive',
'--username=dustin']
if password is not None:
args.append('--password=' + password)
args.extend(['--limit=100', sample_base])
return gpo.Expect(*args)

def test_create_changes_overriden_project(self):
def custom_split_file(path):
Expand Down Expand Up @@ -492,6 +498,32 @@ def check_fourth(_):

return d

def test_poll_empty_password(self):
s = self.attachSVNPoller(sample_base, split_file=split_file,
svnuser='dustin', svnpasswd='')

self.expectCommands(
self.makeInfoExpect(password="").stdout(sample_info_output),
self.makeLogExpect(password="").stdout(make_changes_output(1)),
self.makeLogExpect(password="").stdout(make_changes_output(1)),
self.makeLogExpect(password="").stdout(make_changes_output(2)),
self.makeLogExpect(password="").stdout(make_changes_output(4)),
)
s.poll()

def test_poll_no_password(self):
s = self.attachSVNPoller(sample_base, split_file=split_file,
svnuser='dustin')

self.expectCommands(
self.makeInfoExpect(password=None).stdout(sample_info_output),
self.makeLogExpect(password=None).stdout(make_changes_output(1)),
self.makeLogExpect(password=None).stdout(make_changes_output(1)),
self.makeLogExpect(password=None).stdout(make_changes_output(2)),
self.makeLogExpect(password=None).stdout(make_changes_output(4)),
)
s.poll()

@compat.usesFlushLoggedErrors
def test_poll_get_prefix_exception(self):
s = self.attachSVNPoller(sample_base, split_file=split_file,
Expand Down

0 comments on commit 2d4cbba

Please sign in to comment.