Skip to content

Commit

Permalink
Add unit tests for LRO_USERNAME a LRO_PASSWORD
Browse files Browse the repository at this point in the history
  • Loading branch information
jrohel authored and evan-goode committed Jun 27, 2024
1 parent acc404a commit 1a9d7a1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tests/python/tests/test_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,10 @@ def test_handle_setopt_none_value(self):
h.httpauth = None
h.setopt(librepo.LRO_USERPWD, None)
h.userpwd = None
h.setopt(librepo.LRO_USERNAME, None)
h.username = None
h.setopt(librepo.LRO_PASSWORD, None)
h.password = None
h.setopt(librepo.LRO_PROXY, None)
h.proxy = None
h.setopt(librepo.LRO_PROXYPORT, None) # None sets default value
Expand Down
24 changes: 23 additions & 1 deletion tests/python/tests/test_yum_repo_downloading.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,8 @@ def test_download_repo_01_from_base_auth_secured_web_01(self):
h.checksum = True
self.assertRaises(librepo.LibrepoException, h.perform, (r))

def test_download_repo_01_from_base_auth_secured_web_02(self):
def test_download_repo_01_from_base_auth_secured_web_02_use_userpwd(self):
""" The test uses the deprecated `h.userpwd="username:password"`. """
h = librepo.Handle()
r = librepo.Result()

Expand All @@ -1454,6 +1455,27 @@ def test_download_repo_01_from_base_auth_secured_web_02(self):
self.assertTrue(yum_repo)
self.assertTrue(yum_repomd)

def test_download_repo_01_from_base_auth_secured_web_02(self):
""" The test uses `h.username="username" and `h.password="password"`. """
h = librepo.Handle()
r = librepo.Result()

url = "%s%s%s" % (self.MOCKURL, config.AUTHBASIC, config.REPO_YUM_01_PATH)
h.urls = [url]
h.repotype = librepo.LR_YUMREPO
h.destdir = self.tmpdir
h.checksum = True
h.httpauth = True
h.username = config.AUTH_USER
h.password = config.AUTH_PASS
h.perform(r)

yum_repo = r.getinfo(librepo.LRR_YUM_REPO)
yum_repomd = r.getinfo(librepo.LRR_YUM_REPOMD)

self.assertTrue(yum_repo)
self.assertTrue(yum_repomd)

# Progressbar test

def test_download_repo_01_with_progressbar(self):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ START_TEST(test_handle)
ck_assert(lr_handle_setopt(h, &tmp_err, LRO_MIRRORLIST, "bar"));
ck_assert_ptr_null(tmp_err);
ck_assert(lr_handle_setopt(h, NULL, LRO_USERPWD, "user:pwd"));
ck_assert(lr_handle_setopt(h, NULL, LRO_USERNAME, "user"));
ck_assert(lr_handle_setopt(h, NULL, LRO_PASSWORD, "pwd"));
ck_assert(lr_handle_setopt(h, NULL, LRO_PROXY, "proxy"));
ck_assert(lr_handle_setopt(h, NULL, LRO_PROXYUSERPWD, "proxyuser:pwd"));
ck_assert(lr_handle_setopt(h, NULL, LRO_DESTDIR, "foodir"));
Expand Down

0 comments on commit 1a9d7a1

Please sign in to comment.