forked from 0k/0k-charms
Valentin Lab
6 years ago
2 changed files with 143 additions and 4 deletions
@ -0,0 +1,138 @@ |
|||
#!/bin/bash |
|||
|
|||
exname=$(basename $0) |
|||
|
|||
prefix_cmd=" |
|||
. /etc/shlib |
|||
|
|||
include common |
|||
include parse |
|||
|
|||
. ../lib/common |
|||
|
|||
" |
|||
|
|||
# mock |
|||
relation-get() { |
|||
local key="$1" |
|||
echo "$CFG" | shyaml get-value "$key" 2>/dev/null |
|||
} |
|||
export -f relation-get |
|||
|
|||
cfg-get-value() { |
|||
local key="$1" |
|||
shyaml get-value "$key" 2>/dev/null |
|||
} |
|||
export -f cfg-get-value |
|||
|
|||
get_service_relations() { |
|||
printf "%s\0" "${RELATIONS[@]}" |
|||
} |
|||
export -f get_service_relations |
|||
|
|||
export state_tmpdir=$(mktemp -d -t tmp.XXXXXXXXXX) |
|||
trap "rm -rf \"$state_tmpdir\"" EXIT |
|||
|
|||
## |
|||
## Tests |
|||
## |
|||
|
|||
try " |
|||
__vhost_cfg_normalize_protocol ' |
|||
protocol: both |
|||
'" |
|||
noerror |
|||
is out ',http,https,' |
|||
|
|||
try " |
|||
__vhost_cfg_normalize_protocol ' |
|||
protocol: http |
|||
'" |
|||
noerror |
|||
is out ',http,' |
|||
|
|||
|
|||
try " |
|||
__vhost_cfg_normalize_protocol ' |
|||
protocol: https |
|||
'" |
|||
noerror |
|||
is out ',https,' |
|||
|
|||
try " |
|||
__vhost_cfg_normalize_protocol ' |
|||
protocol: ssl |
|||
'" |
|||
noerror |
|||
is out ',https,' |
|||
|
|||
|
|||
## |
|||
## auto |
|||
## |
|||
|
|||
|
|||
try " |
|||
__vhost_cfg_normalize_protocol ' |
|||
protocol: auto |
|||
'" |
|||
noerror |
|||
is out ',http,' |
|||
|
|||
try " |
|||
__vhost_cfg_normalize_protocol ' |
|||
'" |
|||
noerror |
|||
is out ',http,' |
|||
|
|||
|
|||
try " |
|||
__vhost_cfg_normalize_protocol ' |
|||
ssl: false |
|||
'" |
|||
noerror |
|||
is out ',http,' |
|||
|
|||
|
|||
try " |
|||
__vhost_cfg_normalize_protocol ' |
|||
ssl: null |
|||
'" |
|||
noerror |
|||
is out ',http,' |
|||
|
|||
|
|||
try " |
|||
__vhost_cfg_normalize_protocol ' |
|||
ssl: true |
|||
'" |
|||
noerror |
|||
is out ',http,https,' |
|||
|
|||
|
|||
## This case is special, we have values, but we don't know |
|||
## how if there are any plugin that can use it. For this |
|||
## function's responsibility, we are wanting 'ssl'. |
|||
try " |
|||
__vhost_cfg_normalize_protocol ' |
|||
ssl: xxx |
|||
'" |
|||
noerror |
|||
is out ',http,https,' |
|||
|
|||
|
|||
try " |
|||
RELATIONS=(cert-provider foo a True) |
|||
__vhost_cfg_normalize_protocol ' |
|||
'" "no ssl, but with cert-provider" |
|||
noerror |
|||
is out ',http,https,' |
|||
|
|||
|
|||
try " |
|||
RELATIONS=(cert-provider foo a True) |
|||
__vhost_cfg_normalize_protocol ' |
|||
ssl: false |
|||
'" "with explicit ssl disable, but with cert-provider" |
|||
noerror |
|||
is out ',http,' |
Write
Preview
Loading…
Cancel
Save
Reference in new issue