1 /* 2 * Copyright 2020 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef FCP_SECAGG_TESTING_SERVER_TEST_SECAGG_EXPERIMENTS_H_ 18 #define FCP_SECAGG_TESTING_SERVER_TEST_SECAGG_EXPERIMENTS_H_ 19 20 #include <set> 21 #include <string> 22 23 #include "fcp/secagg/server/experiments_interface.h" 24 25 namespace fcp { 26 namespace secagg { 27 28 // Defines an experiment class to set secagg experiments. 29 class TestSecAggExperiment : public ExperimentsInterface { 30 public: TestSecAggExperiment(const std::set<std::string> & enabled_experiment_names)31 explicit TestSecAggExperiment( 32 const std::set<std::string>& enabled_experiment_names) 33 : enabled_experiment_names_(enabled_experiment_names) {} TestSecAggExperiment(std::string enabled_experiment_name)34 explicit TestSecAggExperiment(std::string enabled_experiment_name) { 35 enabled_experiment_names_ = 36 std::set<std::string>({enabled_experiment_name}); 37 } TestSecAggExperiment()38 explicit TestSecAggExperiment() {} IsEnabled(absl::string_view experiment_name)39 bool IsEnabled(absl::string_view experiment_name) override { 40 return enabled_experiment_names_.find(static_cast<std::string>( 41 experiment_name)) != enabled_experiment_names_.end(); 42 } 43 44 private: 45 std::set<std::string> enabled_experiment_names_; 46 }; 47 48 } // namespace secagg 49 } // namespace fcp 50 51 #endif // FCP_SECAGG_TESTING_SERVER_TEST_SECAGG_EXPERIMENTS_H_ 52