Skip to content

Commit

Permalink
Add tests for WhisperServerService#run
Browse files Browse the repository at this point in the history
Additionally, `LocalWhisperServerService` may be used for integration testing.
  • Loading branch information
eager-signal committed Apr 29, 2024
1 parent b6f8bca commit 0e4be0c
Show file tree
Hide file tree
Showing 84 changed files with 2,157 additions and 553 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ jobs:
# work around an issue with actions/runner setting an incorrect HOME in containers, which breaks maven caching
# https://github.com/actions/setup-java/issues/356
HOME: /root
- name: Install APT packages
# ca-certificates: required for AWS CRT client
run: apt update && apt install -y ca-certificates
- name: Build with Maven
run: ./mvnw -e -B verify
30 changes: 30 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Testing

## Automated tests

The full suite of automated tests can be run using Maven from the project root:

```sh
./mvnw verify
```

## Test server

The service can be run in a feature-limited test mode by running the Maven `integration-test`
goal with the `test-server` profile activated:

```sh
./mvnw integration-test -Ptest-server [-DskipTests=true]
```

This runs [`LocalWhisperServerService`][lwss] with [test configuration][test.yml] and [secrets][test secrets]. External
registration clients are stubbed so that:

- a captcha requirement can be satisfied with `test.test.registration.test`
- any string will be accepted for a phone verification code

[lwss]: service/src/test/java/org/whispersystems/textsecuregcm/LocalWhisperServerService.java

[test.yml]: service/src/test/resources/config/test.yml

[test secrets]: service/src/test/resources/config/test-secrets-bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.whispersystems.textsecuregcm.storage.RegistrationRecoveryPasswordsManager;
import org.whispersystems.textsecuregcm.storage.VerificationSessionManager;
import org.whispersystems.textsecuregcm.storage.VerificationSessions;
import org.whispersystems.textsecuregcm.util.DynamoDbFromConfig;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient;
Expand All @@ -31,13 +30,9 @@ public class IntegrationTools {
public static IntegrationTools create(final Config config) {
final AwsCredentialsProvider credentialsProvider = DefaultCredentialsProvider.builder().build();

final DynamoDbAsyncClient dynamoDbAsyncClient = DynamoDbFromConfig.asyncClient(
config.dynamoDbClientConfiguration(),
credentialsProvider);
final DynamoDbAsyncClient dynamoDbAsyncClient = config.dynamoDbClient().buildAsyncClient(credentialsProvider);

final DynamoDbClient dynamoDbClient = DynamoDbFromConfig.client(
config.dynamoDbClientConfiguration(),
credentialsProvider);
final DynamoDbClient dynamoDbClient = config.dynamoDbClient().buildSyncClient(credentialsProvider);

final RegistrationRecoveryPasswords registrationRecoveryPasswords = new RegistrationRecoveryPasswords(
config.dynamoDbTables().registrationRecovery(), Duration.ofDays(1), dynamoDbClient, dynamoDbAsyncClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

package org.signal.integration.config;

import org.whispersystems.textsecuregcm.configuration.DynamoDbClientConfiguration;
import org.whispersystems.textsecuregcm.configuration.DynamoDbClientFactory;

public record Config(String domain,
String rootCert,
DynamoDbClientConfiguration dynamoDbClientConfiguration,
DynamoDbClientFactory dynamoDbClient,
DynamoDbTables dynamoDbTables,
String prescribedRegistrationNumber,
String prescribedRegistrationCode) {
Expand Down
41 changes: 23 additions & 18 deletions service/config/sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ braintree:
supportedCurrenciesByPaymentMethod:
PAYPAL:
- usd
pubSubProject: example-project
pubSubTopic: example-topic
pubSubCredentialConfiguration: |
{
"credential": "configuration"
}
dynamoDbClientConfiguration:
pubSubPublisher:
project: example-project
topic: example-topic
credentialConfiguration: |
{
"credential": "configuration"
}
dynamoDbClient:
region: us-west-2 # AWS Region

dynamoDbTables:
Expand Down Expand Up @@ -138,8 +139,9 @@ cacheCluster: # Redis server configuration for cache cluster
clientPresenceCluster: # Redis server configuration for client presence cluster
configurationUri: redis://redis.example.com:6379/

pubsub: # Redis server configuration for pubsub cluster
uri: redis://redis.example.com:6379/
provisioning:
pubsub: # Redis server configuration for pubsub cluster
uri: redis://redis.example.com:6379/

pushSchedulerCluster: # Redis server configuration for push scheduler cluster
configurationUri: redis://redis.example.com:6379/
Expand Down Expand Up @@ -218,9 +220,10 @@ metricsCluster:
configurationUri: redis://redis.example.com:6379/

awsAttachments: # AWS S3 configuration
accessKey: secret://awsAttachments.accessKey
accessSecret: secret://awsAttachments.accessSecret
bucket: aws-attachments
credentials:
accessKeyId: secret://awsAttachments.accessKey
secretAccessKey: secret://awsAttachments.accessSecret
region: us-west-2

gcpAttachments: # GCP Storage configuration
Expand All @@ -245,9 +248,10 @@ fcm: # FCM configuration
credentials: secret://fcm.credentials

cdn:
accessKey: secret://cdn.accessKey
accessSecret: secret://cdn.accessSecret
bucket: cdn # S3 Bucket name
credentials:
accessKeyId: secret://cdn.accessKey
secretAccessKey: secret://cdn.accessSecret
region: us-west-2 # AWS region

clientCdn:
Expand Down Expand Up @@ -345,13 +349,14 @@ remoteConfig:

paymentsService:
userAuthenticationTokenSharedSecret: secret://paymentsService.userAuthenticationTokenSharedSecret
fixerApiKey: secret://paymentsService.fixerApiKey
coinMarketCapApiKey: secret://paymentsService.coinMarketCapApiKey
coinMarketCapCurrencyIds:
MOB: 7878
paymentCurrencies:
# list of symbols for supported currencies
- MOB
externalClients:
fixerApiKey: secret://paymentsService.fixerApiKey
coinMarketCapApiKey: secret://paymentsService.coinMarketCapApiKey
coinMarketCapCurrencyIds:
MOB: 7878

artService:
userAuthenticationTokenSharedSecret: secret://artService.userAuthenticationTokenSharedSecret
Expand Down
39 changes: 32 additions & 7 deletions service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,31 @@
</plugins>
</build>
</profile>
<profile>
<id>test-server</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>start-test-server</id>
<phase>integration-test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>org.whispersystems.textsecuregcm.LocalWhisperServerService</mainClass>
<classpathScope>test</classpathScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
Expand Down Expand Up @@ -692,15 +717,15 @@
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>org.whispersystems.textsecuregcm.CheckServiceConfigurations</mainClass>
<classpathScope>test</classpathScope>
<arguments>
<argument>${project.basedir}/config</argument>
</arguments>
</configuration>
</execution>
</executions>
<configuration>
<mainClass>org.whispersystems.textsecuregcm.CheckServiceConfigurations</mainClass>
<classpathScope>test</classpathScope>
<arguments>
<argument>${project.basedir}/config</argument>
</arguments>
</configuration>
</plugin>

<plugin>
Expand Down
Loading

0 comments on commit 0e4be0c

Please sign in to comment.