Просмотр исходного кода

tests: reenable basic auth test and add @ in username

On launchpad #1558484 a user reports that @ in the authentication tokens
parsing of sources.list isn't working in an older (precise) version. It
isn't the recommended way of specifying passwords and co (auth.conf is),
but we can at least test for regressions (and in this case test at all…
who was that "clever" boy disabling a test with exit……… oh, nevermind.

Git-Dch: Ignore
David Kalnischkies лет назад: 10
Родитель
Сommit
28b2efcb19
3 измененных файлов с 17 добавлено и 7 удалено
  1. 2 2
      test/integration/framework
  2. 6 4
      test/integration/test-authentication-basic
  3. 9 1
      test/libapt/uri_test.cc

+ 2 - 2
test/integration/framework

@@ -1156,8 +1156,8 @@ rewritesourceslist() {
 	local APTARCHIVE2="copy://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive" | sed 's# #%20#g')"
 	local APTARCHIVE2="copy://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive" | sed 's# #%20#g')"
 	for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
 	for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
 		sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#$APTARCHIVE2#${1}#" \
 		sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#$APTARCHIVE2#${1}#" \
-			-e "s#http://localhost:${APTHTTPPORT}/#${1}#" \
-			-e "s#https://localhost:${APTHTTPSPORT}/#${1}#"
+			-e "s#http://[^@]*@\?localhost:${APTHTTPPORT}/\?#${1}#" \
+			-e "s#https://[^@]*@\?localhost:${APTHTTPSPORT}/\?#${1}#"
 	done
 	done
 }
 }
 
 

+ 6 - 4
test/integration/test-authentication-basic

@@ -9,9 +9,8 @@ configarchitecture 'i386'
 
 
 insertpackage 'unstable' 'foo' 'all' '1'
 insertpackage 'unstable' 'foo' 'all' '1'
 setupaptarchive --no-update
 setupaptarchive --no-update
-exit
 
 
-changetohttpswebserver --authorization="$(printf '%s' 'star:hunter2' | base64 )"
+changetohttpswebserver --authorization="$(printf '%s' 'star@irc:hunter2' | base64 )"
 
 
 echo 'See, when YOU type hunter2, it shows to us as *******' > aptarchive/bash
 echo 'See, when YOU type hunter2, it shows to us as *******' > aptarchive/bash
 
 
@@ -62,7 +61,7 @@ runtest() {
 
 
 	# good auth
 	# good auth
 	authfile 'machine localhost
 	authfile 'machine localhost
-login star
+login star@irc
 password hunter2'
 password hunter2'
 	testauthsuccess "$1"
 	testauthsuccess "$1"
 
 
@@ -78,7 +77,7 @@ login debian
 password jessie
 password jessie
 
 
 machine localhost
 machine localhost
-login star
+login star@irc
 password hunter2'
 password hunter2'
 	testauthsuccess "$1"
 	testauthsuccess "$1"
 }
 }
@@ -86,6 +85,9 @@ password hunter2'
 msgmsg 'server basic auth'
 msgmsg 'server basic auth'
 rewritesourceslist "http://localhost:${APTHTTPPORT}"
 rewritesourceslist "http://localhost:${APTHTTPPORT}"
 runtest "http://localhost:${APTHTTPPORT}"
 runtest "http://localhost:${APTHTTPPORT}"
+rewritesourceslist "http://star%40irc:hunter2@localhost:${APTHTTPPORT}"
+authfile ''
+testauthsuccess "http://star%40irc:hunter2@localhost:${APTHTTPPORT}"
 rewritesourceslist "https://localhost:${APTHTTPSPORT}"
 rewritesourceslist "https://localhost:${APTHTTPSPORT}"
 runtest "https://localhost:${APTHTTPSPORT}"
 runtest "https://localhost:${APTHTTPSPORT}"
 rewritesourceslist "http://localhost:${APTHTTPPORT}"
 rewritesourceslist "http://localhost:${APTHTTPPORT}"

+ 9 - 1
test/libapt/uri_test.cc

@@ -159,7 +159,7 @@ TEST(URITest, RFC2732)
    EXPECT_EQ("cdrom://Foo Bar Cow", URI::SiteOnly(U));
    EXPECT_EQ("cdrom://Foo Bar Cow", URI::SiteOnly(U));
    EXPECT_EQ("cdrom://Foo Bar Cow/debian", URI::ArchiveOnly(U));
    EXPECT_EQ("cdrom://Foo Bar Cow/debian", URI::ArchiveOnly(U));
    EXPECT_EQ("cdrom://Foo Bar Cow/debian/", URI::NoUserPassword(U));
    EXPECT_EQ("cdrom://Foo Bar Cow/debian/", URI::NoUserPassword(U));
-   // percent encoded
+   // percent encoded password
    U = URI("ftp://foo:b%40r@example.org");
    U = URI("ftp://foo:b%40r@example.org");
    EXPECT_EQ("foo", U.User);
    EXPECT_EQ("foo", U.User);
    EXPECT_EQ("b@r", U.Password);
    EXPECT_EQ("b@r", U.Password);
@@ -167,4 +167,12 @@ TEST(URITest, RFC2732)
    EXPECT_EQ("ftp://example.org", URI::SiteOnly(U));
    EXPECT_EQ("ftp://example.org", URI::SiteOnly(U));
    EXPECT_EQ("ftp://example.org", URI::ArchiveOnly(U));
    EXPECT_EQ("ftp://example.org", URI::ArchiveOnly(U));
    EXPECT_EQ("ftp://example.org/", URI::NoUserPassword(U));
    EXPECT_EQ("ftp://example.org/", URI::NoUserPassword(U));
+   // percent encoded user
+   U = URI("ftp://f%40o:bar@example.org");
+   EXPECT_EQ("f@o", U.User);
+   EXPECT_EQ("bar", U.Password);
+   EXPECT_EQ("ftp://f%40o:bar@example.org/", (std::string) U);
+   EXPECT_EQ("ftp://example.org", URI::SiteOnly(U));
+   EXPECT_EQ("ftp://example.org", URI::ArchiveOnly(U));
+   EXPECT_EQ("ftp://example.org/", URI::NoUserPassword(U));
 }
 }