Implement the tor_family_identity resource
This commit is contained in:
parent
0951242b32
commit
ec57a47ba2
22 changed files with 558 additions and 67 deletions
49
e2e-tests/obfs4/README.md
Normal file
49
e2e-tests/obfs4/README.md
Normal file
|
@ -0,0 +1,49 @@
|
|||
# End-to-End Testing
|
||||
|
||||
This directory contains a complete end-to-end test setup for the terraform-provider-tor.
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. **Setup development environment:**
|
||||
```bash
|
||||
./setup-dev.sh
|
||||
```
|
||||
This script will:
|
||||
- Create local `.terraformrc` with dev overrides (no global config changes)
|
||||
- Build and install the provider locally
|
||||
|
||||
2. **Run the test:**
|
||||
```bash
|
||||
./tf plan
|
||||
./tf apply
|
||||
```
|
||||
|
||||
Or using the full command:
|
||||
```bash
|
||||
TF_CLI_CONFIG_FILE=.terraformrc terraform plan
|
||||
TF_CLI_CONFIG_FILE=.terraformrc terraform apply
|
||||
```
|
||||
|
||||
Note: Skip `terraform init` when using dev overrides - it's not needed and may cause errors.
|
||||
|
||||
3. **Clean up:**
|
||||
```bash
|
||||
./tf destroy
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If you encounter issues:
|
||||
|
||||
1. **Provider not found**: Run `./setup-dev.sh` again
|
||||
2. **Build errors**: Check that Go >= 1.23 is installed
|
||||
3. **Permission errors**: Ensure the setup script is executable
|
||||
|
||||
## Resetting
|
||||
|
||||
To reset your Terraform configuration:
|
||||
```bash
|
||||
rm -rf .terraform/ .terraform.lock.hcl terraform.tfstate*
|
||||
```
|
||||
|
||||
Then run the setup and init process again.
|
72
e2e-tests/obfs4/main.tf
Normal file
72
e2e-tests/obfs4/main.tf
Normal file
|
@ -0,0 +1,72 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
tor = {
|
||||
source = "guardianproject/tor"
|
||||
version = "99.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "tor" {}
|
||||
|
||||
# Generate RSA identity key for the bridge
|
||||
resource "tor_relay_identity_rsa" "bridge" {}
|
||||
|
||||
# Generate Ed25519 identity key for the bridge
|
||||
resource "tor_relay_identity_ed25519" "bridge" {}
|
||||
|
||||
# Generate family identity for the bridge
|
||||
resource "tor_family_identity" "bridge" {
|
||||
family_name = "MyBridgeFamily"
|
||||
}
|
||||
|
||||
# Generate obfs4 state using the identity keys
|
||||
resource "tor_obfs4_state" "bridge" {
|
||||
rsa_identity_private_key = tor_relay_identity_rsa.bridge.private_key_pem
|
||||
ed25519_identity_private_key = tor_relay_identity_ed25519.bridge.private_key_pem
|
||||
}
|
||||
|
||||
# Generate bridge line for client distribution
|
||||
data "tor_obfs4_bridge_line" "bridge" {
|
||||
ip_address = "203.0.113.1"
|
||||
port = 9001
|
||||
identity_fingerprint_sha1 = tor_relay_identity_rsa.bridge.public_key_fingerprint_sha1
|
||||
obfs4_state_certificate = tor_obfs4_state.bridge.certificate
|
||||
obfs4_state_iat_mode = tor_obfs4_state.bridge.iat_mode
|
||||
}
|
||||
|
||||
# Outputs for verification
|
||||
output "rsa_fingerprint_sha1" {
|
||||
description = "RSA identity fingerprint (SHA1)"
|
||||
value = tor_relay_identity_rsa.bridge.public_key_fingerprint_sha1
|
||||
}
|
||||
|
||||
output "rsa_fingerprint_sha256" {
|
||||
description = "RSA identity fingerprint (SHA256)"
|
||||
value = tor_relay_identity_rsa.bridge.public_key_fingerprint_sha256
|
||||
}
|
||||
|
||||
output "ed25519_fingerprint_sha256" {
|
||||
description = "Ed25519 identity fingerprint (SHA256)"
|
||||
value = tor_relay_identity_ed25519.bridge.public_key_fingerprint_sha256
|
||||
}
|
||||
|
||||
output "obfs4_certificate" {
|
||||
description = "obfs4 certificate for bridge line"
|
||||
value = tor_obfs4_state.bridge.certificate
|
||||
}
|
||||
|
||||
output "obfs4_iat_mode" {
|
||||
description = "obfs4 IAT mode"
|
||||
value = tor_obfs4_state.bridge.iat_mode
|
||||
}
|
||||
|
||||
output "bridge_line" {
|
||||
description = "Complete bridge line for clients"
|
||||
value = data.tor_obfs4_bridge_line.bridge.bridge_line
|
||||
}
|
||||
|
||||
output "family_id" {
|
||||
description = "Family ID for the bridge"
|
||||
value = tor_family_identity.bridge.id
|
||||
}
|
15
e2e-tests/obfs4/terraformrc
Normal file
15
e2e-tests/obfs4/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/*"
|
||||
]
|
||||
}
|
||||
}
|
7
e2e-tests/obfs4/test.sh
Executable file
7
e2e-tests/obfs4/test.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
set -e
|
||||
../setup.sh
|
||||
rm -f terraform.tfstate*
|
||||
./tf init
|
||||
./tf plan
|
||||
./tf apply -auto-approve
|
3
e2e-tests/obfs4/tf
Executable file
3
e2e-tests/obfs4/tf
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
export TF_CLI_CONFIG_FILE=terraformrc
|
||||
exec tofu "$@"
|
Loading…
Add table
Add a link
Reference in a new issue