mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 21:12:28 +00:00
Tests: replace openssl base64 with base64
This commit is contained in:
parent
4f66a6651a
commit
2e5acb2bdd
@ -119,7 +119,7 @@ urls=(
|
|||||||
|
|
||||||
|
|
||||||
base64URLEncode() {
|
base64URLEncode() {
|
||||||
echo -n "$1" | openssl base64 -e -A | tr '+/' '-_' | tr -d '='
|
echo -n "$1" | base64 -w0 | tr '+/' '-_' | tr -d '='
|
||||||
}
|
}
|
||||||
|
|
||||||
base64URLDecode() {
|
base64URLDecode() {
|
||||||
@ -128,7 +128,7 @@ base64URLDecode() {
|
|||||||
if [ $len -eq 2 ]; then result="$1"'=='
|
if [ $len -eq 2 ]; then result="$1"'=='
|
||||||
elif [ $len -eq 3 ]; then result="$1"'='
|
elif [ $len -eq 3 ]; then result="$1"'='
|
||||||
fi
|
fi
|
||||||
echo "$result" | tr '_-' '/+' | openssl base64 -d -A
|
echo "$result" | tr '_-' '/+' | base64 -w0 -d
|
||||||
}
|
}
|
||||||
|
|
||||||
test_compare_to_gold_encode() {
|
test_compare_to_gold_encode() {
|
||||||
@ -158,12 +158,10 @@ test_compare_to_gold_decode() {
|
|||||||
|
|
||||||
test_compare_to_self() {
|
test_compare_to_self() {
|
||||||
local input="$1"
|
local input="$1"
|
||||||
local encode=$(${CLICKHOUSE_CLIENT} --query="SELECT base64URLEncode('$input')")
|
local decode=$(${CLICKHOUSE_CLIENT} --query="SELECT base64URLDecode(base64URLEncode('$input'))")
|
||||||
local decode=$(${CLICKHOUSE_CLIENT} --query="SELECT base64URLDecode('$encode')")
|
|
||||||
|
|
||||||
if [ "$decode" != "$input" ]; then
|
if [ "$decode" != "$input" ]; then
|
||||||
echo "Input: $input"
|
echo "Input: $input"
|
||||||
echo "Encode: $encode"
|
|
||||||
echo "Got: $decode"
|
echo "Got: $decode"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -181,10 +179,8 @@ for url in "${urls[@]}"; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# special case for '
|
# special case for '
|
||||||
encode=$(${CLICKHOUSE_CLIENT} --query="SELECT base64URLEncode('http://example.com/!$&\'()*+,;=:@/path')")
|
decode=$(${CLICKHOUSE_CLIENT} --query="SELECT base64URLDecode(base64URLEncode('http://example.com/!$&\'()*+,;=:@/path'))")
|
||||||
decode=$(${CLICKHOUSE_CLIENT} --query="SELECT base64URLDecode('$encode')")
|
|
||||||
if [ "$decode" != "http://example.com/!$&\'()*+,;=:@/path" ]; then
|
if [ "$decode" != "http://example.com/!$&\'()*+,;=:@/path" ]; then
|
||||||
echo "Special case fail"
|
echo "Special case fail"
|
||||||
echo "Encode: $encode"
|
|
||||||
echo "Got: $decode"
|
echo "Got: $decode"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user