Fix experiments in BackupAuthManager
This commit is contained in:
parent
a9b5359f7c
commit
e7d1eadf8e
|
@ -700,7 +700,7 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
|
||||||
ServerZkReceiptOperations zkReceiptOperations = new ServerZkReceiptOperations(zkSecretParams);
|
ServerZkReceiptOperations zkReceiptOperations = new ServerZkReceiptOperations(zkSecretParams);
|
||||||
|
|
||||||
Cdn3BackupCredentialGenerator cdn3BackupCredentialGenerator = new Cdn3BackupCredentialGenerator(config.getTus());
|
Cdn3BackupCredentialGenerator cdn3BackupCredentialGenerator = new Cdn3BackupCredentialGenerator(config.getTus());
|
||||||
BackupAuthManager backupAuthManager = new BackupAuthManager(dynamicConfigurationManager, rateLimiters, accountsManager, backupsGenericZkSecretParams, clock);
|
BackupAuthManager backupAuthManager = new BackupAuthManager(experimentEnrollmentManager, rateLimiters, accountsManager, backupsGenericZkSecretParams, clock);
|
||||||
BackupsDb backupsDb = new BackupsDb(
|
BackupsDb backupsDb = new BackupsDb(
|
||||||
dynamoDbAsyncClient,
|
dynamoDbAsyncClient,
|
||||||
config.getDynamoDbTables().getBackups().getTableName(),
|
config.getDynamoDbTables().getBackups().getTableName(),
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.signal.libsignal.zkgroup.backups.BackupAuthCredentialRequest;
|
||||||
import org.signal.libsignal.zkgroup.backups.BackupAuthCredentialResponse;
|
import org.signal.libsignal.zkgroup.backups.BackupAuthCredentialResponse;
|
||||||
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.controllers.RateLimitExceededException;
|
import org.whispersystems.textsecuregcm.controllers.RateLimitExceededException;
|
||||||
|
import org.whispersystems.textsecuregcm.experiment.ExperimentEnrollmentManager;
|
||||||
import org.whispersystems.textsecuregcm.limits.RateLimiters;
|
import org.whispersystems.textsecuregcm.limits.RateLimiters;
|
||||||
import org.whispersystems.textsecuregcm.storage.Account;
|
import org.whispersystems.textsecuregcm.storage.Account;
|
||||||
import org.whispersystems.textsecuregcm.storage.AccountsManager;
|
import org.whispersystems.textsecuregcm.storage.AccountsManager;
|
||||||
|
@ -43,19 +44,19 @@ public class BackupAuthManager {
|
||||||
final static String BACKUP_EXPERIMENT_NAME = "backup";
|
final static String BACKUP_EXPERIMENT_NAME = "backup";
|
||||||
final static String BACKUP_MEDIA_EXPERIMENT_NAME = "backupMedia";
|
final static String BACKUP_MEDIA_EXPERIMENT_NAME = "backupMedia";
|
||||||
|
|
||||||
private final DynamicConfigurationManager<DynamicConfiguration> dynamicConfigurationManager;
|
private final ExperimentEnrollmentManager experimentEnrollmentManager;
|
||||||
private final GenericServerSecretParams serverSecretParams;
|
private final GenericServerSecretParams serverSecretParams;
|
||||||
private final Clock clock;
|
private final Clock clock;
|
||||||
private final RateLimiters rateLimiters;
|
private final RateLimiters rateLimiters;
|
||||||
private final AccountsManager accountsManager;
|
private final AccountsManager accountsManager;
|
||||||
|
|
||||||
public BackupAuthManager(
|
public BackupAuthManager(
|
||||||
final DynamicConfigurationManager<DynamicConfiguration> dynamicConfigurationManager,
|
final ExperimentEnrollmentManager experimentEnrollmentManager,
|
||||||
final RateLimiters rateLimiters,
|
final RateLimiters rateLimiters,
|
||||||
final AccountsManager accountsManager,
|
final AccountsManager accountsManager,
|
||||||
final GenericServerSecretParams serverSecretParams,
|
final GenericServerSecretParams serverSecretParams,
|
||||||
final Clock clock) {
|
final Clock clock) {
|
||||||
this.dynamicConfigurationManager = dynamicConfigurationManager;
|
this.experimentEnrollmentManager = experimentEnrollmentManager;
|
||||||
this.rateLimiters = rateLimiters;
|
this.rateLimiters = rateLimiters;
|
||||||
this.accountsManager = accountsManager;
|
this.accountsManager = accountsManager;
|
||||||
this.serverSecretParams = serverSecretParams;
|
this.serverSecretParams = serverSecretParams;
|
||||||
|
@ -157,9 +158,6 @@ public class BackupAuthManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean inExperiment(final String experimentName, final Account account) {
|
private boolean inExperiment(final String experimentName, final Account account) {
|
||||||
return dynamicConfigurationManager.getConfiguration()
|
return this.experimentEnrollmentManager.isEnrolled(account.getUuid(), experimentName);
|
||||||
.getExperimentEnrollmentConfiguration(experimentName)
|
|
||||||
.map(config -> config.getEnrolledUuids().contains(account.getUuid()))
|
|
||||||
.orElse(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.whispersystems.textsecuregcm.tests.util;
|
||||||
|
|
||||||
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicExperimentEnrollmentConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicExperimentEnrollmentConfiguration;
|
||||||
|
import org.whispersystems.textsecuregcm.experiment.ExperimentEnrollmentManager;
|
||||||
import org.whispersystems.textsecuregcm.storage.DynamicConfigurationManager;
|
import org.whispersystems.textsecuregcm.storage.DynamicConfigurationManager;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -17,7 +18,7 @@ import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class ExperimentHelper {
|
public class ExperimentHelper {
|
||||||
|
|
||||||
public static DynamicConfigurationManager<DynamicConfiguration> withEnrollment(
|
private static DynamicConfigurationManager<DynamicConfiguration> withEnrollment(
|
||||||
final String experimentName,
|
final String experimentName,
|
||||||
final Set<UUID> enrolledUuids,
|
final Set<UUID> enrolledUuids,
|
||||||
final int enrollmentPercentage) {
|
final int enrollmentPercentage) {
|
||||||
|
@ -31,11 +32,11 @@ public class ExperimentHelper {
|
||||||
return dcm;
|
return dcm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DynamicConfigurationManager<DynamicConfiguration> withEnrollment(final String experimentName, final Set<UUID> enrolledUuids) {
|
public static ExperimentEnrollmentManager withEnrollment(final String experimentName, final Set<UUID> enrolledUuids) {
|
||||||
return withEnrollment(experimentName, enrolledUuids, 0);
|
return new ExperimentEnrollmentManager(withEnrollment(experimentName, enrolledUuids, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DynamicConfigurationManager<DynamicConfiguration> withEnrollment(final String experimentName, final UUID enrolledUuid) {
|
public static ExperimentEnrollmentManager withEnrollment(final String experimentName, final UUID enrolledUuid) {
|
||||||
return withEnrollment(experimentName, Set.of(enrolledUuid), 0);
|
return new ExperimentEnrollmentManager(withEnrollment(experimentName, Set.of(enrolledUuid), 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue