summaryrefslogtreecommitdiff
path: root/tests/data/cmd-fake
blob: e363651bb1627d44f195276224187996bb408502 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
# $Id$
#
# This is a fake wallet backend that returns bogus data for verification by
# the client test suite.  It doesn't test any of the wallet server code.

command="$1"
shift
type="$1"
if [ "$1" != "keytab" ] ; then
    echo "Unknown object type $1" >&2
    exit 1
fi
shift
if [ "$command" = "attr" ] ; then
    if [ -n "$4" ] ; then
        echo "Too many arguments" >&2
        exit 1
    fi
    if [ "$2" != sync ] ; then
        echo "Unknown attribute $2" >&2
        exit 1
    fi
fi
if [ "$command" != "attr" ] && [ -n "$2" ] ; then
    echo "Too many arguments" >&2
    exit 1
fi

case "$command" in
attr)
    case "$1" in
    service/fake-srvtab)
        if [ -n "$3" ] ; then
            if [ "$3" != "kaserver" ] ; then
                echo "Invalid attribute value $3" >&2
                exit 1
            fi
            touch sync-kaserver
        else
            if [ -f sync-kaserver ] ; then
                echo "kaserver"
            fi
        fi
        ;;
    *)
        echo "Looking at sync attribute of wrong keytab" >&2
        exit 1
        ;;
    esac
    ;;
get)
    case "$1" in
    service/fake-test)
        cat data/fake-data
        exit 0
        ;;
    service/fake-srvtab)
        cat data/fake-keytab
        exit 0
        ;;
    *)
        echo "Unknown keytab $1" >&2
        exit 1
        ;;
    esac
    ;;
show)
    if [ "$1" = "service/fake-test" ] ; then
        echo "Some stuff about $1"
        exit 0
    else
        echo "Unknown keytab $1" >&2
        exit 1
    fi
    ;;
expires)
    echo "Expiration date of $1"
    exit 0
    ;;
*)
    echo "Unknown command $command" >&2
    exit 1
    ;;
esac