aboutsummaryrefslogtreecommitdiff
path: root/ascension/test/test_ascension_simple.sh
blob: 47fd298f60371c5c13ab8ebfadf3066821c4b7d4 (plain) (blame)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
# Copyright (C) 2019 rexxnor
# License AGPLv3+: GNU AGPL version 3 or later <https://www.gnu.org/licenses/agpl.html>
# This is free software: you are free to change and redistribute it.
# There is NO WARRANTY, to the extent permitted by law.
#
# Returns 1 on basic error
# Returns 2 on explicit test case errors
# Returns 3 on implicit test case errors


# Shutdown named
function cleanup {
    pkill named
    gnunet-identity -D gnunet.org
}

# Check for required packages

if ! [ -x "$(command -v named)" ]; then
    echo 'bind/named is not installed' >&2
    exit 1
fi

if ! [ -x "$(command -v ascension)" ]; then
    echo 'ascension is not installed' >&2
    exit 1
fi

if ! [ -x "$(command -v gnunet-arm)" ]; then
    echo 'gnunet is not installed' >&2
    exit 1
fi

gnunet-arm -T 1s -I
if [ "$?" -ne 0 ]; then
    echo "The gnunet peer is not running" >&2
    exit 1
fi

# Start named with a simple zone
named -c basic_named.conf -p 5000

# Check if domain resolves
nslookup gnunet.org 127.0.0.1 -port=5000
if [ "$?" -ne 0 ]; then
    echo "Something went wrong with named"
    cleanup
    exit 1
fi

# Let ascension run on gnunet.org test domain
ascension gnunet.org -n 127.0.0.1 -p 5000 -s -d
if [ "$?" -ne 0 ]; then
    echo "ascension failed adding the records!"
    cleanup
    exit 1
fi

function checkfailexp  {
    if [ "$?" -ne 0 ]; then
        echo "required record not present"
        cleanup
        exit 2
    fi
}

function checkfailimp  {
    if [ "$?" -ne 0 ]; then
        echo "implied record not present"
        cleanup
        exit 3
    fi
}

# TESTING explicit records
gnunet-gns -t CNAME -u asdf.gnunet.org
checkfailexp
gnunet-gns -t AAAA -u foo.gnunet.org
checkfailexp
gnunet-gns -t A -u mail.gnunet.org
checkfailexp
gnunet-gns -t A -u ns1.gnunet.org
checkfailexp
gnunet-gns -t A -u ns2.gnunet.org
checkfailexp
gnunet-gns -t A -u ns2.gnunet.org
checkfailexp
gnunet-gns -t MX -u mail.gnunet.org
checkfailexp
gnunet-gns -t A -u nextcloud.gnunet.org
checkfailexp
gnunet-gns -t SOA -u @.gnunet.org
checkfailexp

# cleanup if we get this far
cleanup

# finish
echo "All records added successfully!!"