From 0cffb091c30b20e343c23df166af4ae2ba390942 Mon Sep 17 00:00:00 2001 From: Bretton Date: Sun, 19 Oct 2025 16:27:19 -0700 Subject: [PATCH] test: update integration tests for .community. handle format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update all integration tests to use singular .community. naming convention instead of .communities. Tests updated: - E2E community creation and XRPC endpoint tests - HostedBy security validation tests - Community provisioning tests - Service integration tests - V2 validation tests - Token refresh tests Changes: - Update expected handle formats in assertions - Update test fixtures to use new convention - Ensure regex patterns match .community. format All tests passing with new handle format. šŸ¤– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- tests/integration/community_e2e_test.go | 6 ++--- .../community_hostedby_security_test.go | 24 +++++++++---------- .../community_provisioning_test.go | 18 +++++++------- .../community_service_integration_test.go | 4 ++-- .../community_v2_validation_test.go | 16 ++++++------- tests/integration/token_refresh_test.go | 4 ++-- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/tests/integration/community_e2e_test.go b/tests/integration/community_e2e_test.go index ce22024..8f2477e 100644 --- a/tests/integration/community_e2e_test.go +++ b/tests/integration/community_e2e_test.go @@ -158,7 +158,7 @@ func TestCommunity_E2E(t *testing.T) { // ==================================================================================== t.Run("1. Write-Forward to PDS", func(t *testing.T) { // Use shorter names to avoid "Handle too long" errors - // atProto handles max: 63 chars, format: name.communities.coves.social + // atProto handles max: 63 chars, format: name.community.coves.social communityName := fmt.Sprintf("e2e-%d", time.Now().Unix()) createReq := communities.CreateCommunityRequest{ @@ -190,9 +190,9 @@ func TestCommunity_E2E(t *testing.T) { // V2: Verify PDS account was created for the community t.Logf("\nšŸ” V2: Verifying community PDS account exists...") - expectedHandle := fmt.Sprintf("%s.communities.%s", communityName, instanceDomain) + expectedHandle := fmt.Sprintf("%s.community.%s", communityName, instanceDomain) t.Logf(" Expected handle: %s", expectedHandle) - t.Logf(" (Using subdomain: *.communities.%s)", instanceDomain) + t.Logf(" (Using subdomain: *.community.%s)", instanceDomain) accountDID, accountHandle, err := queryPDSAccount(pdsURL, expectedHandle) if err != nil { diff --git a/tests/integration/community_hostedby_security_test.go b/tests/integration/community_hostedby_security_test.go index 5266748..3c99c3b 100644 --- a/tests/integration/community_hostedby_security_test.go +++ b/tests/integration/community_hostedby_security_test.go @@ -41,7 +41,7 @@ func TestHostedByVerification_DomainMatching(t *testing.T) { RKey: "self", CID: "bafy123abc", Record: map[string]interface{}{ - "handle": "gaming.communities.coves.social", // coves.social handle + "handle": "gaming.community.coves.social", // coves.social handle "name": "gaming", "displayName": "Nintendo Gaming", "description": "Fake Nintendo community", @@ -97,7 +97,7 @@ func TestHostedByVerification_DomainMatching(t *testing.T) { RKey: "self", CID: "bafy123abc", Record: map[string]interface{}{ - "handle": "gaming.communities.coves.social", // coves.social handle + "handle": "gaming.community.coves.social", // coves.social handle "name": "gaming", "displayName": "Gaming Community", "description": "Legitimate coves.social community", @@ -149,7 +149,7 @@ func TestHostedByVerification_DomainMatching(t *testing.T) { RKey: "self", CID: "bafy123abc", Record: map[string]interface{}{ - "handle": "gaming.communities.coves.social", + "handle": "gaming.community.coves.social", "name": "gaming", "displayName": "Test Community", "description": "Test", @@ -193,7 +193,7 @@ func TestHostedByVerification_DomainMatching(t *testing.T) { RKey: "self", CID: "bafy123abc", Record: map[string]interface{}{ - "handle": "gaming.communities.example.com", + "handle": "gaming.community.example.com", "name": "gaming", "displayName": "Test", "description": "Test", @@ -245,7 +245,7 @@ func TestExtractDomainFromHandle(t *testing.T) { }{ { name: "DNS-style handle with subdomain", - handle: "gaming.communities.coves.social", + handle: "gaming.community.coves.social", hostedByDID: "did:web:coves.social", shouldSucceed: true, }, @@ -257,44 +257,44 @@ func TestExtractDomainFromHandle(t *testing.T) { }, { name: "Multi-part subdomain", - handle: "gaming.test.communities.example.com", + handle: "gaming.test.community.example.com", hostedByDID: "did:web:example.com", shouldSucceed: true, }, { name: "Mismatched domain", - handle: "gaming.communities.coves.social", + handle: "gaming.community.coves.social", hostedByDID: "did:web:example.com", shouldSucceed: false, }, // CRITICAL: Multi-part TLD tests (PR review feedback) { name: "Multi-part TLD: .co.uk", - handle: "gaming.communities.coves.co.uk", + handle: "gaming.community.coves.co.uk", hostedByDID: "did:web:coves.co.uk", shouldSucceed: true, }, { name: "Multi-part TLD: .com.au", - handle: "gaming.communities.example.com.au", + handle: "gaming.community.example.com.au", hostedByDID: "did:web:example.com.au", shouldSucceed: true, }, { name: "Multi-part TLD: Reject incorrect .co.uk extraction", - handle: "gaming.communities.coves.co.uk", + handle: "gaming.community.coves.co.uk", hostedByDID: "did:web:co.uk", // Wrong! Should be coves.co.uk shouldSucceed: false, }, { name: "Multi-part TLD: .org.uk", - handle: "gaming.communities.myinstance.org.uk", + handle: "gaming.community.myinstance.org.uk", hostedByDID: "did:web:myinstance.org.uk", shouldSucceed: true, }, { name: "Multi-part TLD: .ac.uk", - handle: "gaming.communities.university.ac.uk", + handle: "gaming.community.university.ac.uk", hostedByDID: "did:web:university.ac.uk", shouldSucceed: true, }, diff --git a/tests/integration/community_provisioning_test.go b/tests/integration/community_provisioning_test.go index fd0e26d..c67c9d6 100644 --- a/tests/integration/community_provisioning_test.go +++ b/tests/integration/community_provisioning_test.go @@ -29,7 +29,7 @@ func TestCommunityRepository_PasswordEncryption(t *testing.T) { community := &communities.Community{ DID: generateTestDID(uniqueSuffix), - Handle: fmt.Sprintf("test-encryption-%s.communities.test.local", uniqueSuffix), + Handle: fmt.Sprintf("test-encryption-%s.community.test.local", uniqueSuffix), Name: "test-encryption", DisplayName: "Test Encryption", Description: "Testing password encryption", @@ -100,7 +100,7 @@ func TestCommunityRepository_PasswordEncryption(t *testing.T) { community := &communities.Community{ DID: generateTestDID(uniqueSuffix), - Handle: fmt.Sprintf("test-empty-pass-%s.communities.test.local", uniqueSuffix), + Handle: fmt.Sprintf("test-empty-pass-%s.community.test.local", uniqueSuffix), Name: "test-empty-pass", DisplayName: "Test Empty Password", Description: "Testing empty password handling", @@ -332,7 +332,7 @@ func TestPasswordSecurity(t *testing.T) { community := &communities.Community{ DID: generateTestDID(uniqueSuffix), - Handle: fmt.Sprintf("pwd-unique-%s.communities.test.local", uniqueSuffix), + Handle: fmt.Sprintf("pwd-unique-%s.community.test.local", uniqueSuffix), Name: fmt.Sprintf("pwd-unique-%s", uniqueSuffix), DisplayName: fmt.Sprintf("Password Unique Test %d", i), Description: "Testing password uniqueness", @@ -402,7 +402,7 @@ func TestPasswordSecurity(t *testing.T) { community := &communities.Community{ DID: generateTestDID(uniqueSuffix), - Handle: fmt.Sprintf("test-pwd-len-%s.communities.test.local", uniqueSuffix), + Handle: fmt.Sprintf("test-pwd-len-%s.community.test.local", uniqueSuffix), Name: "test-pwd-len", DisplayName: "Test Password Length", Description: "Testing password length requirements", @@ -470,7 +470,7 @@ func TestConcurrentProvisioning(t *testing.T) { uniqueSuffix := fmt.Sprintf("%d-%d", time.Now().UnixNano(), idx) community := &communities.Community{ DID: generateTestDID(uniqueSuffix), - Handle: fmt.Sprintf("%s.communities.test.local", sameName), + Handle: fmt.Sprintf("%s.community.test.local", sameName), Name: sameName, DisplayName: "Concurrent Test", Description: "Testing concurrent creation", @@ -530,7 +530,7 @@ func TestConcurrentProvisioning(t *testing.T) { uniqueSuffix := fmt.Sprintf("%d", time.Now().UnixNano()) community := &communities.Community{ DID: generateTestDID(uniqueSuffix), - Handle: fmt.Sprintf("read-test-%s.communities.test.local", uniqueSuffix), + Handle: fmt.Sprintf("read-test-%s.community.test.local", uniqueSuffix), Name: "read-test", DisplayName: "Read Test", Description: "Testing concurrent reads", @@ -719,7 +719,7 @@ func TestTokenValidation(t *testing.T) { community := &communities.Community{ DID: generateTestDID(uniqueSuffix), - Handle: fmt.Sprintf("token-test-%s.communities.test.local", uniqueSuffix), + Handle: fmt.Sprintf("token-test-%s.community.test.local", uniqueSuffix), Name: "token-test", DisplayName: "Token Test", Description: "Testing token storage", @@ -784,7 +784,7 @@ func TestTokenValidation(t *testing.T) { community := &communities.Community{ DID: generateTestDID(uniqueSuffix), - Handle: fmt.Sprintf("empty-token-%s.communities.test.local", uniqueSuffix), + Handle: fmt.Sprintf("empty-token-%s.community.test.local", uniqueSuffix), Name: "empty-token", DisplayName: "Empty Token Test", Description: "Testing empty token handling", @@ -832,7 +832,7 @@ func TestTokenValidation(t *testing.T) { community := &communities.Community{ DID: generateTestDID(uniqueSuffix), - Handle: fmt.Sprintf("encrypted-token-%s.communities.test.local", uniqueSuffix), + Handle: fmt.Sprintf("encrypted-token-%s.community.test.local", uniqueSuffix), Name: "encrypted-token", DisplayName: "Encrypted Token Test", Description: "Testing token encryption", diff --git a/tests/integration/community_service_integration_test.go b/tests/integration/community_service_integration_test.go index 6c8b234..34cb13f 100644 --- a/tests/integration/community_service_integration_test.go +++ b/tests/integration/community_service_integration_test.go @@ -55,7 +55,7 @@ func TestCommunityService_CreateWithRealPDS(t *testing.T) { t.Run("creates community with real PDS provisioning", func(t *testing.T) { // Create provisioner and service (production code path) - // Use coves.social domain (configured in PDS_SERVICE_HANDLE_DOMAINS as .communities.coves.social) + // Use coves.social domain (configured in PDS_SERVICE_HANDLE_DOMAINS as .community.coves.social) provisioner := communities.NewPDSAccountProvisioner("coves.social", pdsURL) service := communities.NewCommunityService( repo, @@ -114,7 +114,7 @@ func TestCommunityService_CreateWithRealPDS(t *testing.T) { t.Logf("āœ… Real DID generated: %s", community.DID) // Verify handle format - expectedHandle := fmt.Sprintf("%s.communities.coves.social", uniqueName) + expectedHandle := fmt.Sprintf("%s.community.coves.social", uniqueName) if community.Handle != expectedHandle { t.Errorf("Expected handle %s, got %s", expectedHandle, community.Handle) } diff --git a/tests/integration/community_v2_validation_test.go b/tests/integration/community_v2_validation_test.go index 2dcad2f..75ad686 100644 --- a/tests/integration/community_v2_validation_test.go +++ b/tests/integration/community_v2_validation_test.go @@ -34,7 +34,7 @@ func TestCommunityConsumer_V2RKeyValidation(t *testing.T) { CID: "bafyreigaming123", Record: map[string]interface{}{ "$type": "social.coves.community.profile", - "handle": "gaming.communities.coves.social", + "handle": "gaming.community.coves.social", "name": "gaming", "createdBy": "did:plc:user123", "hostedBy": "did:web:coves.social", @@ -83,7 +83,7 @@ func TestCommunityConsumer_V2RKeyValidation(t *testing.T) { CID: "bafyreiv1community", Record: map[string]interface{}{ "$type": "social.coves.community.profile", - "handle": "v1community.communities.coves.social", + "handle": "v1community.community.coves.social", "name": "v1community", "createdBy": "did:plc:user456", "hostedBy": "did:web:coves.social", @@ -129,7 +129,7 @@ func TestCommunityConsumer_V2RKeyValidation(t *testing.T) { CID: "bafyreicustom", Record: map[string]interface{}{ "$type": "social.coves.community.profile", - "handle": "custom.communities.coves.social", + "handle": "custom.community.coves.social", "name": "custom", "createdBy": "did:plc:user789", "hostedBy": "did:web:coves.social", @@ -168,7 +168,7 @@ func TestCommunityConsumer_V2RKeyValidation(t *testing.T) { CID: "bafyreiupdate1", Record: map[string]interface{}{ "$type": "social.coves.community.profile", - "handle": "updatetest.communities.coves.social", + "handle": "updatetest.community.coves.social", "name": "updatetest", "createdBy": "did:plc:userUpdate", "hostedBy": "did:web:coves.social", @@ -199,7 +199,7 @@ func TestCommunityConsumer_V2RKeyValidation(t *testing.T) { CID: "bafyreiupdate2", Record: map[string]interface{}{ "$type": "social.coves.community.profile", - "handle": "updatetest.communities.coves.social", + "handle": "updatetest.community.coves.social", "name": "updatetest", "displayName": "Updated Name", "createdBy": "did:plc:userUpdate", @@ -258,7 +258,7 @@ func TestCommunityConsumer_HandleField(t *testing.T) { CID: "bafyreihandle", Record: map[string]interface{}{ "$type": "social.coves.community.profile", - "handle": "gamingtest.communities.coves.social", // atProto handle (DNS-resolvable) + "handle": "gamingtest.community.coves.social", // atProto handle (DNS-resolvable) "name": "gamingtest", // Short name for !mentions "createdBy": "did:plc:user123", "hostedBy": "did:web:coves.social", @@ -284,8 +284,8 @@ func TestCommunityConsumer_HandleField(t *testing.T) { } // Verify the atProto handle is stored - if community.Handle != "gamingtest.communities.coves.social" { - t.Errorf("Expected handle gamingtest.communities.coves.social, got %s", community.Handle) + if community.Handle != "gamingtest.community.coves.social" { + t.Errorf("Expected handle gamingtest.community.coves.social, got %s", community.Handle) } // Note: The DID is the authoritative identifier for atProto resolution diff --git a/tests/integration/token_refresh_test.go b/tests/integration/token_refresh_test.go index 28fc7d4..984925b 100644 --- a/tests/integration/token_refresh_test.go +++ b/tests/integration/token_refresh_test.go @@ -110,7 +110,7 @@ func TestTokenRefresh_UpdateCredentials(t *testing.T) { // Create a test community first community := &communities.Community{ DID: "did:plc:test123", - Handle: "test.communities.coves.social", + Handle: "test.community.coves.social", Name: "test", OwnerDID: "did:plc:test123", CreatedByDID: "did:plc:creator", @@ -186,7 +186,7 @@ func TestTokenRefresh_E2E_UpdateAfterTokenRefresh(t *testing.T) { community := &communities.Community{ DID: "did:plc:expiring123", - Handle: "expiring.communities.coves.social", + Handle: "expiring.community.coves.social", Name: "expiring", OwnerDID: "did:plc:expiring123", CreatedByDID: "did:plc:creator", -- 2.51.2