Implement the tor_family_identity resource
This commit is contained in:
parent
0951242b32
commit
ec57a47ba2
22 changed files with 558 additions and 67 deletions
44
e2e-tests/tor-family/main.tf
Normal file
44
e2e-tests/tor-family/main.tf
Normal file
|
@ -0,0 +1,44 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
tor = {
|
||||
source = "guardianproject/tor"
|
||||
version = "99.0.0"
|
||||
}
|
||||
local = {
|
||||
source = "hashicorp/local"
|
||||
version = "2.5.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "tor" {}
|
||||
|
||||
resource "tor_family_identity" "this" {
|
||||
family_name = "MyFamily"
|
||||
}
|
||||
|
||||
resource "local_sensitive_file" "family_key" {
|
||||
content_base64 = tor_family_identity.this.secret_key
|
||||
filename = "./data/keys/MyKey.secret_family_key"
|
||||
file_permission = "0600"
|
||||
}
|
||||
|
||||
resource "local_file" "this" {
|
||||
filename = "./torrc"
|
||||
content = <<EOF
|
||||
FamilyId ${tor_family_identity.this.id}
|
||||
BridgeRelay 1
|
||||
DataDirectory data
|
||||
ORPort 3333
|
||||
ServerTransportListenAddr obfs4 0.0.0.0:3334
|
||||
ExtORPort auto
|
||||
ContactInfo <address@email.com>
|
||||
Nickname PickANickname
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
output "family_id" {
|
||||
description = "Family ID for the bridge"
|
||||
value = tor_family_identity.this.id
|
||||
}
|
15
e2e-tests/tor-family/terraformrc
Normal file
15
e2e-tests/tor-family/terraformrc
Normal file
|
@ -0,0 +1,15 @@
|
|||
provider_installation {
|
||||
filesystem_mirror {
|
||||
path = "./providers"
|
||||
include = [
|
||||
"registry.terraform.io/guardianproject/*",
|
||||
"registry.opentofu.org/guardianproject/*"
|
||||
]
|
||||
}
|
||||
direct {
|
||||
exclude = [
|
||||
"registry.terraform.io/guardianproject/*",
|
||||
"registry.opentofu.org/guardianproject/*"
|
||||
]
|
||||
}
|
||||
}
|
34
e2e-tests/tor-family/test.sh
Executable file
34
e2e-tests/tor-family/test.sh
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env sh
|
||||
set -e
|
||||
../setup.sh
|
||||
rm -f terraform.tfstate*
|
||||
./tf init
|
||||
./tf plan
|
||||
./tf apply -auto-approve
|
||||
|
||||
set +e
|
||||
|
||||
# Start tor and let it run for a few seconds
|
||||
echo "Starting Tor to verify family key..."
|
||||
timeout 5 tor -f ./torrc >tor.log 2>&1
|
||||
TOR_EXIT_CODE=$?
|
||||
|
||||
set -e
|
||||
|
||||
# Check if tor exited with an error (not due to timeout)
|
||||
# timeout returns 124 when it kills the process
|
||||
if [ $TOR_EXIT_CODE -ne 0 ] && [ $TOR_EXIT_CODE -ne 124 ]; then
|
||||
echo "ERROR: Tor exited with error code $TOR_EXIT_CODE"
|
||||
cat tor.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if tor started bootstrapping (indicates successful key loading)
|
||||
if grep -q "Bootstrapped [0-9]" tor.log; then
|
||||
echo "SUCCESS: Tor started bootstrapping with generated family key"
|
||||
exit 0
|
||||
else
|
||||
echo "ERROR: Tor did not start bootstrapping"
|
||||
cat tor.log
|
||||
exit 1
|
||||
fi
|
4
e2e-tests/tor-family/tf
Executable file
4
e2e-tests/tor-family/tf
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
# Wrapper script to run terraform with local config
|
||||
export TF_CLI_CONFIG_FILE=terraformrc
|
||||
exec tofu "$@"
|
Loading…
Add table
Add a link
Reference in a new issue