-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (144 loc) · 6.7 KB
/
integration.yaml
File metadata and controls
180 lines (144 loc) · 6.7 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
---
name: Integration
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
jobs:
integration:
name: Integration
runs-on: ubuntu-24.04
strategy:
matrix:
py_version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
secondary: ["BIND9", "Knot"]
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Enable Python ${{ matrix.py_version }}
id: setup-python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.py_version }}
- name: Set BIND9 test environment variables
if: matrix.secondary == 'BIND9'
run: |
echo "GHA_SZH_DAEMON=BIND9" >> "$GITHUB_ENV"
echo "GHA_SZH_CFILE=devel/zone-handler.yaml.bind.in" >> "$GITHUB_ENV"
- name: Set Knot test environment variables
if: matrix.secondary == 'Knot'
run: |
echo "GHA_SZH_DAEMON=Knot" >> "$GITHUB_ENV"
echo "GHA_SZH_CFILE=devel/zone-handler.yaml.knot.in" >> "$GITHUB_ENV"
- name: Install Knot
if: matrix.secondary == 'Knot'
run: |
sudo ln -s /dev/null /etc/systemd/system/knot.service
sudo apt-get install --yes knot
- name: Install named
run: |
sudo ln -s /dev/null /etc/systemd/system/named.service
sudo apt-get install --yes bind9
- name: Extend named apparmor profile
run: |
sudo install --owner=root --group=root --mode=0644 --no-target-directory devel/apparmor_local_named /etc/apparmor.d/local/usr.sbin.named
sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.named
- name: Create system user for primary named service
run: sudo adduser --no-create-home --home /var/cache/primary --group --system primary
- name: Bind to additional localhost ip for primary named service
run: sudo ip address add 127.0.0.7/8 dev lo
- name: Create directories for primary named service
run: |
sudo install --owner=root --group=root --mode=0755 --directory /etc/primary /etc/primary/zones
sudo install --owner=root --group=primary --mode=0775 --directory /var/cache/primary
- name: Install example zone(s) on primary named service
run: |
sudo install --owner=root --group=root --mode=0644 --no-target-directory devel/example-zone /etc/primary/zones/example.com.zone
sudo install --owner=root --group=root --mode=0644 --no-target-directory devel/example-zone /etc/primary/zones/example.net.zone
sudo install --owner=root --group=root --mode=0644 --no-target-directory devel/example-zone /etc/primary/zones/example.org.zone
- name: Provide configuration for primary named service
run: >
sudo install --owner=root --group=root --mode=0644
devel/primary/named.conf devel/primary/named.conf.options devel/primary/named.conf.local
/etc/primary/
- name: Provide systemd service for primary named service
run: sudo install --owner=root --group=root --mode=0644 devel/primary/primary.service /etc/systemd/system/
- name: Start primary named services
run: sudo systemctl start primary.service
- name: Provide configuration for secondary regular named service
if: matrix.secondary == 'BIND9'
run: >
sudo install --owner=root --group=root --mode=0644
devel/named/named.conf.options devel/named/named.conf.local
/etc/bind/
- name: Start secondary named services
if: matrix.secondary == 'BIND9'
run: |
sudo rm /etc/systemd/system/named.service
sudo systemctl start named.service
- name: Provide configuration for Knot
if: matrix.secondary == 'Knot'
run: sudo install --owner=root --group=root --mode=0644 devel/knot/knot.conf /etc/knot/
- name: Start Knot services
if: matrix.secondary == 'Knot'
run: |
sudo rm /etc/systemd/system/knot.service
sudo systemctl start knot.service
- name: Create sanely owned /myopt
run: sudo install --owner=root --group=root --mode=0755 --directory /myopt
- name: Install ssh-zone-handler
run: |
sudo "$python_binary" -m venv /myopt/ssh-zone-handler
sudo /myopt/ssh-zone-handler/bin/pip3 install .
env:
python_binary: ${{ steps.setup-python.outputs.python-path }}
- name: Create Alice's ssh key
run: ssh-keygen -t ed25519 -N '' -f ~/.ssh/id_alice_ed25519 -C alice
- name: Generate /etc/zone-handler.yaml
run: >
sed -e "s#__ALICE_SSH_KEY__#$(cat ~/.ssh/id_alice_ed25519.pub)#" < "$GHA_SZH_CFILE"
| sudo install --owner=root --group=root --mode=0644 --no-target-directory /dev/stdin /etc/zone-handler.yaml
- name: Run szh-verify command against known good config files
run: |
/myopt/ssh-zone-handler/bin/szh-verify ./tests/data/knot-example-config.yaml
/myopt/ssh-zone-handler/bin/szh-verify ./tests/data/bind-example-config.yaml
/myopt/ssh-zone-handler/bin/szh-verify ./tests/data/bind-alternative-config.yaml
- name: Run szh-verify command against non-existing config file
run: |
if /myopt/ssh-zone-handler/bin/szh-verify ./completly-bogus-filename; then
echo "Failed to fail expected fail."; exit 1
fi
- name: Run szh-verify command against invalid config file
run: |
if /myopt/ssh-zone-handler/bin/szh-verify ./tests/data/outdated-config.yaml; then
echo "Failed to fail expected fail."; exit 1
fi
- name: Setup user accounts
run: |
sudo adduser --comment "Zone Handler" --disabled-password --shell /bin/dash zones
sudo adduser --system --ingroup systemd-journal szh-logviewer
sudo adduser --system szh-sshdcmd
- name: Generate sudoers file
run: >
/myopt/ssh-zone-handler/bin/szh-sudoers
| sudo EDITOR="tee" visudo -f /etc/sudoers.d/zone-handler
- name: Install sshd
run: sudo apt-get install --yes openssh-server
- name: Update sshd configuration
run: |
sed -e "s#__INSTALL_PATH__#/myopt/ssh-zone-handler#" < devel/sshd_match.in | sudo tee --append /etc/ssh/sshd_config
sudo systemctl restart ssh.service
- name: Prime ~/.ssh/known_hosts
run: echo "127.0.0.1 $(cat /etc/ssh/ssh_host_ed25519_key.pub)" >> ~/.ssh/known_hosts
- name: Run test
run: |
mkdir ./devel/.dynamic
cp ./devel/gha_alice_ssh_conf ./devel/.dynamic/ssh_conf
/usr/bin/python3 ./integration/run-integration-tests "$GHA_SZH_DAEMON"