|
58 | 58 | import org.opensearch.cluster.routing.UnassignedInfo;
|
59 | 59 | import org.opensearch.common.lucene.Lucene;
|
60 | 60 | import org.opensearch.common.settings.ClusterSettings;
|
| 61 | +import org.opensearch.common.settings.Setting; |
61 | 62 | import org.opensearch.common.settings.Settings;
|
62 | 63 | import org.opensearch.core.common.unit.ByteSizeUnit;
|
63 | 64 | import org.opensearch.core.index.shard.ShardId;
|
|
70 | 71 | import org.opensearch.indices.recovery.RecoveryState;
|
71 | 72 | import org.opensearch.indices.replication.common.ReplicationLuceneIndex;
|
72 | 73 | import org.opensearch.repositories.IndexId;
|
| 74 | +import org.opensearch.repositories.blobstore.BlobStoreRepository; |
73 | 75 | import org.opensearch.repositories.blobstore.BlobStoreTestUtil;
|
74 | 76 | import org.opensearch.snapshots.Snapshot;
|
75 | 77 | import org.opensearch.snapshots.SnapshotId;
|
|
90 | 92 |
|
91 | 93 | import static java.util.Collections.emptyMap;
|
92 | 94 | import static java.util.Collections.emptySet;
|
| 95 | +import static org.hamcrest.Matchers.is; |
93 | 96 |
|
94 | 97 | public class FsRepositoryTests extends OpenSearchTestCase {
|
95 | 98 |
|
@@ -218,6 +221,31 @@ public void testSnapshotAndRestore() throws IOException, InterruptedException {
|
218 | 221 | }
|
219 | 222 | }
|
220 | 223 |
|
| 224 | + public void testRestrictedSettingsDefault() { |
| 225 | + Path repo = createTempDir(); |
| 226 | + Settings settings = Settings.builder() |
| 227 | + .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toAbsolutePath()) |
| 228 | + .put(Environment.PATH_REPO_SETTING.getKey(), repo.toAbsolutePath()) |
| 229 | + .put("location", repo) |
| 230 | + .put(FsRepository.BASE_PATH_SETTING.getKey(), "my_base_path") |
| 231 | + .build(); |
| 232 | + RepositoryMetadata metadata = new RepositoryMetadata("test", "fs", settings); |
| 233 | + FsRepository repository = new FsRepository( |
| 234 | + metadata, |
| 235 | + new Environment(settings, null), |
| 236 | + NamedXContentRegistry.EMPTY, |
| 237 | + BlobStoreTestUtil.mockClusterService(), |
| 238 | + new RecoverySettings(settings, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)) |
| 239 | + ); |
| 240 | + |
| 241 | + List<Setting<?>> restrictedSettings = repository.getRestrictedSystemRepositorySettings(); |
| 242 | + assertThat(restrictedSettings.size(), is(4)); |
| 243 | + assertTrue(restrictedSettings.contains(BlobStoreRepository.SYSTEM_REPOSITORY_SETTING)); |
| 244 | + assertTrue(restrictedSettings.contains(BlobStoreRepository.READONLY_SETTING)); |
| 245 | + assertTrue(restrictedSettings.contains(BlobStoreRepository.REMOTE_STORE_INDEX_SHALLOW_COPY)); |
| 246 | + assertTrue(restrictedSettings.contains(FsRepository.LOCATION_SETTING)); |
| 247 | + } |
| 248 | + |
221 | 249 | private void runGeneric(ThreadPool threadPool, Runnable runnable) throws InterruptedException {
|
222 | 250 | CountDownLatch latch = new CountDownLatch(1);
|
223 | 251 | threadPool.generic().submit(() -> {
|
|
0 commit comments