28
28
import static org .opensearch .node .remotestore .RemoteStoreNodeAttribute .REMOTE_STORE_REPOSITORY_CRYPTO_SETTINGS_PREFIX ;
29
29
import static org .opensearch .node .remotestore .RemoteStoreNodeAttribute .REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX ;
30
30
import static org .opensearch .node .remotestore .RemoteStoreNodeAttribute .REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT ;
31
+ import static org .opensearch .node .remotestore .RemoteStoreNodeAttribute .REPOSITORY_CRYPTO_ATTRIBUTE_KEY_FORMAT ;
32
+ import static org .opensearch .node .remotestore .RemoteStoreNodeAttribute .REPOSITORY_CRYPTO_SETTINGS_PREFIX ;
33
+ import static org .opensearch .node .remotestore .RemoteStoreNodeAttribute .REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX ;
34
+ import static org .opensearch .node .remotestore .RemoteStoreNodeAttribute .REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT ;
35
+ import static org .opensearch .test .RemoteStoreAttributeConstants .REMOTE_PUBLICATION_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY ;
36
+ import static org .opensearch .test .RemoteStoreAttributeConstants .REMOTE_PUBLICATION_SEGMENT_REPOSITORY_NAME_ATTRIBUTE_KEY ;
37
+ import static org .opensearch .test .RemoteStoreAttributeConstants .REMOTE_PUBLICATION_TRANSLOG_REPOSITORY_NAME_ATTRIBUTE_KEY ;
31
38
import static org .opensearch .test .RemoteStoreAttributeConstants .REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY ;
32
39
import static org .opensearch .test .RemoteStoreAttributeConstants .REMOTE_STORE_ROUTING_TABLE_REPOSITORY_NAME_ATTRIBUTE_KEY ;
33
40
import static org .opensearch .test .RemoteStoreAttributeConstants .REMOTE_STORE_SEGMENT_REPOSITORY_NAME_ATTRIBUTE_KEY ;
@@ -37,7 +44,52 @@ public class RemoteStoreNodeAttributeTests extends OpenSearchTestCase {
37
44
38
45
static private final String KEY_ARN = "arn:aws:kms:us-east-1:123456789:key/6e9aa906-2cc3-4924-8ded-f385c78d9dcf" ;
39
46
static private final String REGION = "us-east-1" ;
47
+ public void testCryptoMetadataForPublication () throws UnknownHostException {
48
+ String repoName = "remote-store-A" ;
49
+ String prefix = "remote_publication" ;
50
+ String repoTypeSettingKey = String .format (Locale .ROOT , REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT , prefix , repoName );
51
+ String repoSettingsKey = String .format (Locale .ROOT , REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX , prefix ,repoName );
52
+ String repoCryptoMetadataKey = String .format (Locale .ROOT , REPOSITORY_CRYPTO_ATTRIBUTE_KEY_FORMAT , prefix ,repoName );
53
+ String repoCryptoMetadataSettingsKey = String .format (Locale .ROOT , REPOSITORY_CRYPTO_SETTINGS_PREFIX , prefix , repoName );
54
+ Map <String , String > attr = Map .of (
55
+ REMOTE_PUBLICATION_SEGMENT_REPOSITORY_NAME_ATTRIBUTE_KEY ,
56
+ repoName ,
57
+ REMOTE_PUBLICATION_TRANSLOG_REPOSITORY_NAME_ATTRIBUTE_KEY ,
58
+ repoName ,
59
+ REMOTE_PUBLICATION_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY ,
60
+ repoName ,
61
+ repoTypeSettingKey ,
62
+ "s3" ,
63
+ repoSettingsKey ,
64
+ "abc" ,
65
+ repoSettingsKey + "base_path" ,
66
+ "xyz" ,
67
+ repoCryptoMetadataKey + ".key_provider_name" ,
68
+ "store-test" ,
69
+ repoCryptoMetadataKey + ".key_provider_type" ,
70
+ "aws-kms" ,
71
+ repoCryptoMetadataSettingsKey + ".region" ,
72
+ REGION ,
73
+ repoCryptoMetadataSettingsKey + ".key_arn" ,
74
+ KEY_ARN
75
+ );
76
+ DiscoveryNode node = new DiscoveryNode (
77
+ "C" ,
78
+ new TransportAddress (InetAddress .getByName ("localhost" ), 9876 ),
79
+ attr ,
80
+ emptySet (),
81
+ Version .CURRENT
82
+ );
40
83
84
+ RemoteStoreNodeAttribute remoteStoreNodeAttribute = new RemoteStoreNodeAttribute (node );
85
+ assertEquals (remoteStoreNodeAttribute .getRepositoriesMetadata ().repositories ().size (), 1 );
86
+ RepositoryMetadata repositoryMetadata = remoteStoreNodeAttribute .getRepositoriesMetadata ().repositories ().get (0 );
87
+ Settings .Builder settings = Settings .builder ();
88
+ settings .put ("region" , REGION );
89
+ settings .put ("key_arn" , KEY_ARN );
90
+ CryptoMetadata cryptoMetadata = new CryptoMetadata ("store-test" , "aws-kms" , settings .build ());
91
+ assertEquals (cryptoMetadata , repositoryMetadata .cryptoMetadata ());
92
+ }
41
93
public void testCryptoMetadata () throws UnknownHostException {
42
94
String repoName = "remote-store-A" ;
43
95
String repoTypeSettingKey = String .format (Locale .ROOT , REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT , repoName );
0 commit comments