Compare commits
35 Commits
suites/uns
...
suites/chi
Author | SHA1 | Date |
---|---|---|
|
3220383220 | 2 years ago |
|
3297fb8d0c | 2 years ago |
|
0b02fd6419 | 2 years ago |
|
595dd37873 | 2 years ago |
![]() |
1f89991636 | 2 years ago |
![]() |
014f31cd9c | 2 years ago |
|
77a1cd746e | 2 years ago |
|
f2b9d293f7 | 2 years ago |
|
c5a8b05fa9 | 2 years ago |
![]() |
aec1df017c | 2 years ago |
![]() |
0bfc3bf326 | 2 years ago |
![]() |
da4b5ea3ec | 2 years ago |
![]() |
693603f07c | 2 years ago |
![]() |
b94bf145d6 | 2 years ago |
![]() |
c7736967bb | 2 years ago |
![]() |
30979216fc | 2 years ago |
![]() |
b7ec379023 | 2 years ago |
![]() |
d4b7b085c7 | 2 years ago |
![]() |
c932fade2a | 2 years ago |
![]() |
781152dcb3 | 2 years ago |
![]() |
dbdee8d78a | 2 years ago |
![]() |
2b557da5b5 | 2 years ago |
![]() |
6e1e896ab0 | 2 years ago |
![]() |
07b429ef82 | 2 years ago |
![]() |
c35d056359 | 2 years ago |
|
7caf4726a4 | 2 years ago |
|
81e5e051c8 | 2 years ago |
|
cdc15a11dc | 2 years ago |
![]() |
0a0566a0bc | 2 years ago |
![]() |
c091472587 | 2 years ago |
![]() |
d4c60c8178 | 2 years ago |
![]() |
3cb755c244 | 2 years ago |
![]() |
7286253180 | 2 years ago |
![]() |
188039d366 | 2 years ago |
![]() |
4042233116 | 2 years ago |
29 changed files with 420 additions and 84 deletions
@ -0,0 +1,43 @@ |
|||
#!/bin/sh |
|||
set -e |
|||
|
|||
TESTDIR="$(readlink -f "$(dirname "$0")")" |
|||
. "$TESTDIR/framework" |
|||
|
|||
setupenvironment |
|||
configarchitecture "i386" |
|||
|
|||
# Disable sandbox to avoid W: down below |
|||
echo 'APT::Sandbox::User "root";' > rootdir/etc/apt/apt.conf.d/no-acquire-sandbox |
|||
|
|||
echo 'alright' > aptarchive/working |
|||
changetohttpswebserver |
|||
|
|||
msgtest 'download of a file works via' 'http' |
|||
testsuccess --nomsg downloadfile "http://localhost:${APTHTTPPORT}/working" httpsfile |
|||
testfileequal httpsfile 'alright' |
|||
rm -f httpfile httpsfile |
|||
|
|||
msgtest 'download of a file works via' 'https' |
|||
testsuccess --nomsg downloadfile "https://localhost:${APTHTTPSPORT}/working" httpfile |
|||
testfileequal httpfile 'alright' |
|||
rm -f httpfile httpsfile |
|||
|
|||
# Speak wrong protocols (https on http port and vice versa). We check that they can be retried. |
|||
|
|||
msgtest 'protocol negotiation error is transient for' 'https' |
|||
testfailureequal "Ign:1 https://localhost:${APTHTTPPORT}/working |
|||
Could not wait for server fd - select (11: Resource temporarily unavailable) |
|||
Err:1 https://localhost:${APTHTTPPORT}/working |
|||
Could not wait for server fd - select (11: Resource temporarily unavailable) |
|||
E: Failed to fetch https://localhost:${APTHTTPPORT}/working Could not wait for server fd - select (11: Resource temporarily unavailable) |
|||
E: Download Failed" apthelper download-file "https://localhost:${APTHTTPPORT}/working" httpfile -oAcquire::https::Timeout=1 -oAcquire::Retries=1 |
|||
|
|||
# Speak wrong protocols (https on http port and vice versa) |
|||
msgtest 'protocol negotiation error is transient for' 'http' |
|||
testfailureequal "Ign:1 http://localhost:${APTHTTPSPORT}/working |
|||
Connection failed |
|||
Err:1 http://localhost:${APTHTTPSPORT}/working |
|||
Connection failed |
|||
E: Failed to fetch http://localhost:${APTHTTPSPORT}/working Connection failed |
|||
E: Download Failed" apthelper download-file "http://localhost:${APTHTTPSPORT}/working" httpfile -oAcquire::https::Timeout=1 -oAcquire::Retries=1 |
@ -0,0 +1,46 @@ |
|||
#!/bin/sh |
|||
set -e |
|||
|
|||
TESTDIR="$(readlink -f "$(dirname "$0")")" |
|||
. "$TESTDIR/framework" |
|||
|
|||
setupenvironment |
|||
configarchitecture "i386" |
|||
confighashes 'SHA512' |
|||
|
|||
mkdir tree |
|||
head -c $((5*1024)) /dev/urandom > tree/data-file |
|||
|
|||
buildsimplenativepackage 'a' 'all' '1.0' 'stable' |
|||
buildsimplenativepackage 'b' 'all' '1.0' 'stable' '' '' '' '' "$PWD/tree" |
|||
buildsimplenativepackage 'c' 'all' '1.0' 'stable' |
|||
|
|||
setupaptarchive |
|||
changetowebserver |
|||
|
|||
# Disable sandbox |
|||
echo 'APT::Sandbox::User "root";' > rootdir/etc/apt/apt.conf.d/no-acquire-sandbox |
|||
# XXX: Remove temporary hack |
|||
rm rootdir/etc/apt/apt.conf.d/temporary-allow-unsized-packages |
|||
|
|||
testsuccess apt update |
|||
|
|||
for file in rootdir/var/lib/apt/lists/*Packages; do |
|||
awk '!(/^Size/ && ++cnt==2)' $file > $file.new |
|||
mv $file.new $file |
|||
done |
|||
|
|||
|
|||
size_a=$(wc -c aptarchive/pool/a_1.0_all.deb | awk '{print $1}') |
|||
size_b=$(wc -c aptarchive/pool/b_1.0_all.deb | awk '{print $1}') |
|||
size_c=$(wc -c aptarchive/pool/c_1.0_all.deb | awk '{print $1}') |
|||
|
|||
testsuccessequal "Get:1 http://localhost:${APTHTTPPORT} stable/main all a all 1.0 [$size_a B] |
|||
Get:2 http://localhost:${APTHTTPPORT} stable/main all b all 1.0 [$size_b B] |
|||
Get:3 http://localhost:${APTHTTPPORT} stable/main all c all 1.0 [$size_c B]" apt download a b c -o Acquire::AllowUnsizedPackages=true |
|||
|
|||
rm *.deb |
|||
testwarningequal "Get:1 http://localhost:${APTHTTPPORT} stable/main all a all 1.0 [$size_a B] |
|||
Get:2 http://localhost:${APTHTTPPORT} stable/main all b all 1.0 [$size_b B] |
|||
Get:3 http://localhost:${APTHTTPPORT} stable/main all c all 1.0 [$size_c B] |
|||
W: Repository is broken: b:i386 (= 1.0) has no Size information" apt download a b c |
@ -0,0 +1,42 @@ |
|||
#!/bin/sh |
|||
set -e |
|||
|
|||
TESTDIR="$(readlink -f "$(dirname "$0")")" |
|||
. "$TESTDIR/framework" |
|||
setupenvironment |
|||
configarchitecture 'amd64' |
|||
|
|||
buildsimplenativepackage 'foo' 'all' '0+0~0' |
|||
setupaptarchive --no-update |
|||
|
|||
runtest() { |
|||
rm -rf rootdir/var/lib/apt/lists |
|||
testsuccess apt update |
|||
|
|||
cd downloaded |
|||
testsuccess apt download foo |
|||
testsuccess rm 'foo_0+0~0_all.deb' |
|||
testsuccess apt install foo |
|||
|
|||
mv '../aptarchive/pool/foo_0+0~0_all.deb' '../aptarchive/pool/foo_0%3a0+0~0_all.deb' |
|||
testsuccess apt purge foo -y |
|||
testfailure apt download foo |
|||
testfailure apt install foo |
|||
|
|||
sed -i -e 's#_0+0~0_#_0%3a0+0~0_#' ../rootdir/var/lib/apt/lists/*Packages |
|||
testsuccess apt download foo |
|||
# FIXME: we shouldn't take filename from file:/ in 'apt download' |
|||
if [ "$1" = 'file' ]; then |
|||
testsuccess rm 'foo_0%3a0+0~0_all.deb' |
|||
else |
|||
testsuccess rm 'foo_0+0~0_all.deb' |
|||
fi |
|||
testsuccess apt install foo |
|||
|
|||
cd "$TMPWORKINGDIRECTORY" >/dev/null |
|||
mv 'aptarchive/pool/foo_0%3a0+0~0_all.deb' 'aptarchive/pool/foo_0+0~0_all.deb' |
|||
} |
|||
|
|||
runtest 'file' |
|||
changetowebserver |
|||
runtest 'http' |
@ -0,0 +1,69 @@ |
|||
#include <config.h> |
|||
#include "../../apt-private/private-cachefile.cc" |
|||
#include "../../apt-private/private-json-hooks.cc" |
|||
#include <gtest/gtest.h> |
|||
#include <string> |
|||
|
|||
TEST(JsonTest, JsonString) |
|||
{ |
|||
std::ostringstream os; |
|||
|
|||
// Check for escaping backslash and quotation marks, and ensure that we do not change number formatting
|
|||
JsonWriter(os).value("H al\"l\\o").value(17); |
|||
|
|||
EXPECT_EQ("\"H al\\u0022l\\u005Co\"17", os.str()); |
|||
|
|||
for (int i = 0; i <= 0x1F; i++) |
|||
{ |
|||
os.str(""); |
|||
|
|||
JsonWriter(os).encodeString(os, std::string("X") + char(i) + "Z"); |
|||
|
|||
std::string exp; |
|||
strprintf(exp, "\"X\\u%04XZ\"", i); |
|||
|
|||
EXPECT_EQ(exp, os.str()); |
|||
} |
|||
} |
|||
|
|||
TEST(JsonTest, JsonObject) |
|||
{ |
|||
std::ostringstream os; |
|||
|
|||
JsonWriter(os).beginObject().name("key").value("value").endObject(); |
|||
|
|||
EXPECT_EQ("{\"key\":\"value\"}", os.str()); |
|||
} |
|||
|
|||
TEST(JsonTest, JsonArrayAndValues) |
|||
{ |
|||
std::ostringstream os; |
|||
|
|||
JsonWriter(os).beginArray().value(0).value("value").value(1).value(true).endArray(); |
|||
|
|||
EXPECT_EQ("[0,\"value\",1,true]", os.str()); |
|||
} |
|||
TEST(JsonTest, JsonStackRegression) |
|||
{ |
|||
std::ostringstream os; |
|||
|
|||
JsonWriter w(os); |
|||
|
|||
// Nest those things deeply such that we transition states:
|
|||
// object -> array -> object; -> array -> object
|
|||
// Older versions never popped back and got stuck on array state.
|
|||
w.beginObject(); |
|||
w.name("a").beginArray().beginObject().endObject().endArray(); |
|||
w.name("b").beginArray().beginObject().endObject().endArray(); |
|||
w.endObject(); |
|||
|
|||
EXPECT_EQ("{\"a\":[{}],\"b\":[{}]}", os.str()); |
|||
} |
|||
TEST(JsonTest, JsonNull) |
|||
{ |
|||
std::ostringstream os; |
|||
|
|||
JsonWriter(os).value(nullptr); |
|||
|
|||
EXPECT_EQ("null", os.str()); |
|||
} |
Loading…
Reference in new issue