#!/usr/bin/env bash

set -e

uri1="${AUTOPKGTEST_TMP}/uri1"
uri2="${AUTOPKGTEST_TMP}/uri2"
uri3="${AUTOPKGTEST_TMP}/uri3"
mkdir $uri1 $uri2 $uri3

config="${AUTOPKGTEST_TMP}/config"

echo "Creating test file"
testfile="${AUTOPKGTEST_TMP}/testfile"
echo -n "test content" > $testfile
cat $testfile
echo
echo

echo "Splitting test file"
gfsec-split -c $config $testfile "file://$uri1/secret" "file://$uri2/secret" "file://$uri3/secret"
echo

echo "Checking file is removed"
! test -e $testfile
echo

echo "Combining shares"
gfsec-use -c $config -k
grep -q 'test content' $testfile
