diff --git a/cluster/bootstrap.go b/cluster/bootstrap.go index 18c5e09..314ec88 100644 --- a/cluster/bootstrap.go +++ b/cluster/bootstrap.go @@ -82,10 +82,19 @@ func (s *BootstrapService) attemptJoin(seedAddr string) bool { return false } - client := &http.Client{Timeout: 10 * time.Second} - url := fmt.Sprintf("http://%s/members/join", seedAddr) + client := NewAuthenticatedHTTPClient(s.config, 10*time.Second) + protocol := GetProtocol(s.config) + url := fmt.Sprintf("%s://%s/members/join", protocol, seedAddr) - resp, err := client.Post(url, "application/json", bytes.NewBuffer(jsonData)) + req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) + if err != nil { + s.logger.WithError(err).Error("Failed to create join request") + return false + } + req.Header.Set("Content-Type", "application/json") + AddClusterAuthHeaders(req, s.config) + + resp, err := client.Do(req) if err != nil { s.logger.WithFields(logrus.Fields{ "seed": seedAddr, diff --git a/integration_test.sh b/integration_test.sh index e209cf3..af6d3b6 100755 --- a/integration_test.sh +++ b/integration_test.sh @@ -124,7 +124,10 @@ EOF # Test 3: Cluster formation test_cluster_formation() { test_start "2-node cluster formation and Merkle Tree replication" - + + # Shared cluster secret for authentication (Issue #13) + local CLUSTER_SECRET="test-cluster-secret-12345678901234567890" + # Node 1 config cat > cluster1.yaml < cluster2.yaml </dev/null || true mkdir -p conflict1_data conflict2_data - + cd "$SCRIPT_DIR" if go run test_conflict.go "$TEST_DIR/conflict1_data" "$TEST_DIR/conflict2_data"; then cd "$TEST_DIR" - + + # Shared cluster secret for authentication (Issue #13) + local CLUSTER_SECRET="conflict-cluster-secret-1234567890123" + # Create configs cat > conflict1.yaml < conflict2.yaml <