<commit_before>#!/usr/bin/env bats

load common

readonly client_mac_address=de:ad:be:ef:00:00
readonly client_ip_address=192.168.3.11/23
readonly client_hostname=test
readonly gateway_ip_address=172.16.31.10/23
readonly relay_ip_address=10.66.67.1/24
readonly auth_ip=10.66.67.10/24
readonly dhcrelay_pid_file=/run/test-dhcrelay.pid

dhcrelay() {
	ns_exec test-relay dhcrelay -pf "$dhcrelay_pid_file" -4 -a -id eth0 -iu eth1 "$(netaddr.ip "$auth_ip")"
}

ns() {
	ns_exec test-auth "$@"
}

setup() {
	setup_namespace test-auth
	setup_namespace test-relay
	ip link add br-relay up type bridge
	iptables -I FORWARD 1 -m physdev --physdev-is-bridged -i br-relay -o br-relay -j ACCEPT
	link_namespace test-auth br-relay eth0 de:ad:be:ef:00:00
	link_namespace test-relay br-relay eth0
	link_namespace test-relay br-auth eth1
	ns_exec test-relay ip address add "$gateway_ip_address" dev eth0
	ns_exec test-relay ip address add "$relay_ip_address" dev eth1
	dhcrelay
	psql foreign <<-EOF
		TRUNCATE dhcphost;
		INSERT INTO dhcphost VALUES ('${client_mac_address}', '$(netaddr.ip "${client_ip_address}")');
	EOF
	refresh
}

teardown() {
	[[ -f "$dhcrelay_pid_file" ]] && kill "$(<"$dhcrelay_pid_file")" || :
	rm -f "$dhcrelay_pid_file"
	unlink_namespace test-relay eth1
	unlink_namespace test-relay eth0
	unlink_namespace test-auth eth0
	iptables -D FORWARD -m physdev --physdev-is-bridged -i br-relay -o br-relay -j ACCEPT
	ip link delete br-relay
	teardown_namespace test-auth
	teardown_namespace test-relay<commit_msg>Use MAC address from fixture<commit_after>#!/usr/bin/env bats

load common

readonly client_mac_address=de:ad:be:ef:00:00
readonly client_ip_address=192.168.3.11/23
readonly client_hostname=test
readonly gateway_ip_address=172.16.31.10/23
readonly relay_ip_address=10.66.67.1/24
readonly auth_ip=10.66.67.10/24
readonly dhcrelay_pid_file=/run/test-dhcrelay.pid

dhcrelay() {
	ns_exec test-relay dhcrelay -pf "$dhcrelay_pid_file" -4 -a -id eth0 -iu eth1 "$(netaddr.ip "$auth_ip")"
}

ns() {
	ns_exec test-auth "$@"
}

setup() {
	setup_namespace test-auth
	setup_namespace test-relay
	ip link add br-relay up type bridge
	iptables -I FORWARD 1 -m physdev --physdev-is-bridged -i br-relay -o br-relay -j ACCEPT
	link_namespace test-auth br-relay eth0 "$client_mac_address"
	link_namespace test-relay br-relay eth0
	link_namespace test-relay br-auth eth1
	ns_exec test-relay ip address add "$gateway_ip_address" dev eth0
	ns_exec test-relay ip address add "$relay_ip_address" dev eth1
	dhcrelay
	psql foreign <<-EOF
		TRUNCATE dhcphost;
		INSERT INTO dhcphost VALUES ('${client_mac_address}', '$(netaddr.ip "${client_ip_address}")');
	EOF
	refresh
}

teardown() {
	[[ -f "$dhcrelay_pid_file" ]] && kill "$(<"$dhcrelay_pid_file")" || :
	rm -f "$dhcrelay_pid_file"
	unlink_namespace test-relay eth1
	unlink_namespace test-relay eth0
	unlink_namespace test-auth eth0
	iptables -D FORWARD -m physdev --physdev-is-bridged -i br-relay -o br-relay -j ACCEPT
	ip link delete br-relay
	teardown_namespace test-auth
	teardown_namespace test-relay
{'fraction_non_alphanumeric': 0.11625615763546798, 'fraction_numerical': 0.03875205254515599, 'mean_word_length': 4.7798861480075905, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1749466', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1194, 'n_words': 285}