diff --git a/.env b/.env index 94b5d60..d86c46b 100644 --- a/.env +++ b/.env @@ -28,9 +28,9 @@ REDIS_PASSWORD=root # Test Configuration, can be ignored. Used for docker-compose-test.yml SB_COFFEE_NAME=coffee SB_COFFEE_DOMAIN=coffee.com -SB_COFFEE_RPC_ENDPOINT=http://127.0.0.0:8086/ -SB_INSTANCE_DNS_MOCK_COFFEE="coffee.com v=socialbox;sb-rpc=http://127.0.0.0:8086/;sb-key=sig:g59Cf8j1wmQmRg1MkveYbpdiZ-1-_hFU9eRRJmQAwmc;sb-exp=0" +SB_COFFEE_RPC_ENDPOINT=http://coffee_socialbox:8085/ +SB_INSTANCE_DNS_MOCK_COFFEE="coffee.com v=socialbox;sb-rpc=http://coffee_socialbox:8085/;sb-key=sig:g59Cf8j1wmQmRg1MkveYbpdiZ-1-_hFU9eRRJmQAwmc;sb-exp=0" SB_TEAPOT_DOMAIN=teapot.com -SB_TEAPOT_RPC_ENDPOINT=http://127.0.0.0:8087/ -SB_INSTANCE_DNS_MOCK_TEAPOT="teapot.com v=socialbox;sb-rpc=http://127.0.0.0:8087/;sb-key=sig:MDXUuripAo_IAv-EZTEoFhpIdhsXxfMLNunSnQzxYiY;sb-exp=0" \ No newline at end of file +SB_TEAPOT_RPC_ENDPOINT=http://teapot_socialbox:8085/ +SB_INSTANCE_DNS_MOCK_TEAPOT="teapot.com v=socialbox;sb-rpc=http://teapot_socialbox:8085/;sb-key=sig:MDXUuripAo_IAv-EZTEoFhpIdhsXxfMLNunSnQzxYiY;sb-exp=0" \ No newline at end of file diff --git a/coffee_socialbox/config/socialbox.conf b/coffee_socialbox/config/socialbox.conf index 7374a3f..1483880 100755 --- a/coffee_socialbox/config/socialbox.conf +++ b/coffee_socialbox/config/socialbox.conf @@ -3,10 +3,10 @@ "enabled": true, "name": "coffee", "domain": "coffee.com", - "rpc_endpoint": "http://127.0.0.0:8086/", + "rpc_endpoint": "http://coffee_socialbox:8085/", "dns_mocks": { - "teapot.com": "v=socialbox;sb-rpc=http://127.0.0.0:8087/;sb-key=sig:MDXUuripAo_IAv-EZTEoFhpIdhsXxfMLNunSnQzxYiY;sb-exp=0", - "coffee.com": "v=socialbox;sb-rpc=http://127.0.0.0:8086/;sb-key=sig:g59Cf8j1wmQmRg1MkveYbpdiZ-1-_hFU9eRRJmQAwmc;sb-exp=0" + "teapot.com": "v=socialbox;sb-rpc=http://teapot_socialbox:8085/;sb-key=sig:MDXUuripAo_IAv-EZTEoFhpIdhsXxfMLNunSnQzxYiY;sb-exp=0", + "coffee.com": "v=socialbox;sb-rpc=http://coffee_socialbox:8085/;sb-key=sig:g59Cf8j1wmQmRg1MkveYbpdiZ-1-_hFU9eRRJmQAwmc;sb-exp=0" } }, "security": { diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 47c225b..9c3d393 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -19,6 +19,7 @@ services: condition: service_healthy networks: - coffee_network + - shared_network restart: unless-stopped volumes: - ./coffee_socialbox/config:/etc/config @@ -34,7 +35,7 @@ services: # Change these values to match your environment or update the .env file SB_INSTANCE_NAME: ${SB_COFFEE_NAME:-coffee} # Instance name SB_COFFEE_NAME SB_INSTANCE_DOMAIN: ${SB_COFFEE_DOMAIN:-coffee.com} # Instance domain SB_COFFEE_DOMAIN - SB_INSTANCE_RPC_ENDPOINT: ${SB_COFFEE_RPC_ENDPOINT:-http://127.0.0.0:8086/} # Instance RPC endpoint SB_COFFEE_RPC_ENDPOINT + SB_INSTANCE_RPC_ENDPOINT: ${SB_COFFEE_RPC_ENDPOINT:-http://coffee_socialbox:8085/} # Instance RPC endpoint SB_COFFEE_RPC_ENDPOINT SB_LOGGING_CONSOLE_ENABLED: ${SB_LOGGING_CONSOLE_ENABLED:-true} SB_LOGGING_CONSOLE_LEVEL: ${SB_LOGGING_CONSOLE_LEVEL:-debug} SB_LOGGING_FILE_ENABLED: ${SB_LOGGING_FILE_ENABLED:-true} @@ -59,10 +60,10 @@ services: # Usage: SB_INSTANCE_DNS_MOCK_: # Environment Variable name is ignored, only the value is used with the prefix being used to detect # the instance name and the suffix being used to detect the TXT record - SB_INSTANCE_DNS_MOCK_COFFEE: ${SB_INSTANCE_DNS_MOCK_COFFEE:-"coffee.com v=socialbox;sb-rpc=http://127.0.0.0:8086/;sb-key=sig:g59Cf8j1wmQmRg1MkveYbpdiZ-1-_hFU9eRRJmQAwmc;sb-exp=0"} - SB_INSTANCE_DNS_MOCK_TEAPOT: ${SB_INSTANCE_DNS_MOCK_TEAPOT:-"teapot.com v=socialbox;sb-rpc=http://127.0.0.0:8087/;sb-key=sig:MDXUuripAo_IAv-EZTEoFhpIdhsXxfMLNunSnQzxYiY;sb-exp=0"} + SB_INSTANCE_DNS_MOCK_COFFEE: ${SB_INSTANCE_DNS_MOCK_COFFEE:-"coffee.com v=socialbox;sb-rpc=http://coffee_socialbox:8085/;sb-key=sig:g59Cf8j1wmQmRg1MkveYbpdiZ-1-_hFU9eRRJmQAwmc;sb-exp=0"} + SB_INSTANCE_DNS_MOCK_TEAPOT: ${SB_INSTANCE_DNS_MOCK_TEAPOT:-"teapot.com v=socialbox;sb-rpc=http://teapot_socialbox:8085/;sb-key=sig:MDXUuripAo_IAv-EZTEoFhpIdhsXxfMLNunSnQzxYiY;sb-exp=0"} healthcheck: - test: ["CMD", "curl", "-f", "-H", "Request-Type: ping", "${SB_INSTANCE_RPC_ENDPOINT-http://127.0.0.0:8086/}"] + test: ["CMD", "curl", "-f", "-H", "Request-Type: ping", "${SB_INSTANCE_RPC_ENDPOINT-http://coffee_socialbox:8085/}"] interval: 30s timeout: 10s retries: 3 @@ -122,6 +123,7 @@ services: condition: service_healthy networks: - teapot_network + - shared_network restart: unless-stopped volumes: - ./teapot_socialbox/config:/etc/config @@ -137,7 +139,7 @@ services: # Change these values to match your environment or update the .env file SB_INSTANCE_NAME: ${SB_TEAPOT_NAME:-teapot} # Instance name SB_TEAPOT_NAME SB_INSTANCE_DOMAIN: ${SB_TEAPOT_DOMAIN:-teapot.com} # Instance domain SB_TEAPOT_DOMAIN - SB_INSTANCE_RPC_ENDPOINT: ${SB_TEAPOT_RPC_ENDPOINT:-http://127.0.0.0:8087/} # Instance RPC endpoint SB_TEAPOT_RPC_ENDPOINT + SB_INSTANCE_RPC_ENDPOINT: ${SB_TEAPOT_RPC_ENDPOINT:-http://teapot_socialbox:8085/} # Instance RPC endpoint SB_TEAPOT_RPC_ENDPOINT SB_LOGGING_CONSOLE_ENABLED: ${SB_LOGGING_CONSOLE_ENABLED:-true} SB_LOGGING_CONSOLE_LEVEL: ${SB_LOGGING_CONSOLE_LEVEL:-debug} SB_LOGGING_FILE_ENABLED: ${SB_LOGGING_FILE_ENABLED:-true} @@ -162,10 +164,10 @@ services: # Usage: SB_INSTANCE_DNS_MOCK_: # Environment Variable name is ignored, only the value is used with the prefix being used to detect # the instance name and the suffix being used to detect the TXT record - SB_INSTANCE_DNS_MOCK_COFFEE: ${SB_INSTANCE_DNS_MOCK_COFFEE:-"coffee.com v=socialbox;sb-rpc=http://127.0.0.0:8086/;sb-key=sig:g59Cf8j1wmQmRg1MkveYbpdiZ-1-_hFU9eRRJmQAwmc;sb-exp=0"} - SB_INSTANCE_DNS_MOCK_TEAPOT: ${SB_INSTANCE_DNS_MOCK_TEAPOT:-"teapot.com v=socialbox;sb-rpc=http://127.0.0.0:8087/;sb-key=sig:MDXUuripAo_IAv-EZTEoFhpIdhsXxfMLNunSnQzxYiY;sb-exp=0"} + SB_INSTANCE_DNS_MOCK_COFFEE: ${SB_INSTANCE_DNS_MOCK_COFFEE:-"coffee.com v=socialbox;sb-rpc=http://coffee_socialbox:8085/;sb-key=sig:g59Cf8j1wmQmRg1MkveYbpdiZ-1-_hFU9eRRJmQAwmc;sb-exp=0"} + SB_INSTANCE_DNS_MOCK_TEAPOT: ${SB_INSTANCE_DNS_MOCK_TEAPOT:-"teapot.com v=socialbox;sb-rpc=http://teapot_socialbox:8085/;sb-key=sig:MDXUuripAo_IAv-EZTEoFhpIdhsXxfMLNunSnQzxYiY;sb-exp=0"} healthcheck: - test: ["CMD", "curl", "-f", "-H", "Request-Type: ping", "${SB_INSTANCE_RPC_ENDPOINT-http://127.0.0.0:8087/}"] + test: ["CMD", "curl", "-f", "-H", "Request-Type: ping", "${SB_INSTANCE_RPC_ENDPOINT-http://teapot_socialbox:8085/}"] interval: 30s timeout: 10s retries: 3 @@ -226,4 +228,6 @@ networks: name: teapot_network coffee_network: driver: bridge - name: coffee_network \ No newline at end of file + name: coffee_network + shared_network: + driver: bridge \ No newline at end of file diff --git a/teapot_socialbox/config/socialbox.conf b/teapot_socialbox/config/socialbox.conf index d04b1ee..a6e14ed 100755 --- a/teapot_socialbox/config/socialbox.conf +++ b/teapot_socialbox/config/socialbox.conf @@ -3,10 +3,10 @@ "enabled": true, "name": "teapot", "domain": "teapot.com", - "rpc_endpoint": "http://127.0.0.0:8087/", + "rpc_endpoint": "http://teapot_socialbox:8085/", "dns_mocks": { - "teapot.com": "v=socialbox;sb-rpc=http://127.0.0.0:8087/;sb-key=sig:MDXUuripAo_IAv-EZTEoFhpIdhsXxfMLNunSnQzxYiY;sb-exp=0", - "coffee.com": "v=socialbox;sb-rpc=http://127.0.0.0:8086/;sb-key=sig:g59Cf8j1wmQmRg1MkveYbpdiZ-1-_hFU9eRRJmQAwmc;sb-exp=0" + "teapot.com": "v=socialbox;sb-rpc=http://teapot_socialbox:8085/;sb-key=sig:MDXUuripAo_IAv-EZTEoFhpIdhsXxfMLNunSnQzxYiY;sb-exp=0", + "coffee.com": "v=socialbox;sb-rpc=http://coffee_socialbox:8085/;sb-key=sig:g59Cf8j1wmQmRg1MkveYbpdiZ-1-_hFU9eRRJmQAwmc;sb-exp=0" } }, "security": { diff --git a/tests/Socialbox/SocialClientTest.php b/tests/Socialbox/SocialClientTest.php index 0089677..e0a0691 100644 --- a/tests/Socialbox/SocialClientTest.php +++ b/tests/Socialbox/SocialClientTest.php @@ -39,9 +39,17 @@ return 'user' . $randomString . '@' . $domain; } - public function testConnection() :void + private static function registerUser(string $domain): SocialClient { - $coffeeClient = new SocialClient(self::generateUsername('intvo.id')); + $client = new SocialClient(self::generateUsername($domain)); + $client->settingsSetPassword("password"); + $client->settingsSetDisplayName("Example User"); + return $client; + } + + public function testRegistration(): void + { + $coffeeClient = new SocialClient(self::generateUsername(self::COFFEE_DOMAIN)); // Check initial session state $this->assertFalse($coffeeClient->getSessionState()->isAuthenticated()); @@ -58,4 +66,14 @@ $this->assertFalse($coffeeClient->getSessionState()->containsFlag(SessionFlags::REGISTRATION_REQUIRED)); $this->assertTrue($coffeeClient->getSessionState()->isAuthenticated()); } + + public function testResolveDecentralizedPeer(): void + { + $coffeeUser = self::registerUser(self::COFFEE_DOMAIN); + $this->assertTrue($coffeeUser->getSessionState()->isAuthenticated()); + $teapotUser = self::registerUser(self::TEAPOT_DOMAIN); + $this->assertTrue($teapotUser->getSessionState()->isAuthenticated()); + + $coffeePeer = $coffeeUser->resolvePeer($teapotUser->getIdentifiedAs()); + } }