@@ -157,4 +157,78 @@ describe('getReplicationInfo helper', () => {
157157
158158 assert . deepStrictEqual ( replicationInfo , undefined ) ;
159159 } ) ;
160+
161+ it ( 'should get replication info with default StorageClass when rules are enabled' , ( ) => {
162+ const replicationConfig = {
163+ role : 'arn:aws:iam::root:role/s3-replication-role-1,arn:aws:iam::root:role/s3-replication-role-2' ,
164+ rules : [ {
165+ prefix : '' ,
166+ enabled : true ,
167+ } ] ,
168+ destination : 'tosomewhere' ,
169+ } ;
170+ const replicationInfo = _getObjectReplicationInfo ( TEST_CONFIG , replicationConfig ) ;
171+ assert . deepStrictEqual ( replicationInfo , {
172+ status : 'PENDING' ,
173+ backends : [ {
174+ site : 'zenko' ,
175+ status : 'PENDING' ,
176+ dataStoreVersionId : '' ,
177+ } ] ,
178+ content : [ 'METADATA' ] ,
179+ destination : 'tosomewhere' ,
180+ storageClass : 'zenko' ,
181+ role : 'arn:aws:iam::root:role/s3-replication-role-1,arn:aws:iam::root:role/s3-replication-role-2' ,
182+ storageType : '' ,
183+ } ) ;
184+ } ) ;
185+
186+ it ( 'should return undefined with specified StorageClass mode if no replication endpoint is configured' , ( ) => {
187+ const replicationConfig = {
188+ role : 'arn:aws:iam::root:role/s3-replication-role' ,
189+ rules : [ {
190+ prefix : '' ,
191+ enabled : true ,
192+ storageClass : 'awsbackend' ,
193+ } ] ,
194+ destination : 'tosomewhere' ,
195+ } ;
196+ const configWithNoReplicationEndpoint = {
197+ locationConstraints : TEST_CONFIG . locationConstraints ,
198+ replicationEndpoints : [ ] ,
199+ } ;
200+ const replicationInfo = _getObjectReplicationInfo ( configWithNoReplicationEndpoint ,
201+ replicationConfig ) ;
202+ assert . deepStrictEqual ( replicationInfo , {
203+ status : 'PENDING' ,
204+ backends : [ {
205+ site : 'awsbackend' ,
206+ status : 'PENDING' ,
207+ dataStoreVersionId : '' ,
208+ } ] ,
209+ content : [ 'METADATA' ] ,
210+ destination : 'tosomewhere' ,
211+ storageClass : 'awsbackend' ,
212+ role : 'arn:aws:iam::root:role/s3-replication-role' ,
213+ storageType : 'aws_s3' ,
214+ } ) ;
215+ } ) ;
216+
217+ it ( 'should return undefined with default StorageClass if no replication endpoint is configured' , ( ) => {
218+ const replicationConfig = {
219+ role : 'arn:aws:iam::root:role/s3-replication-role-1,arn:aws:iam::root:role/s3-replication-role-2' ,
220+ rules : [ {
221+ prefix : '' ,
222+ enabled : true ,
223+ } ] ,
224+ destination : 'tosomewhere' ,
225+ } ;
226+ const configWithNoReplicationEndpoint = {
227+ locationConstraints : TEST_CONFIG . locationConstraints ,
228+ replicationEndpoints : [ ] ,
229+ } ;
230+ const replicationInfo = _getObjectReplicationInfo ( configWithNoReplicationEndpoint ,
231+ replicationConfig ) ;
232+ assert . deepStrictEqual ( replicationInfo , undefined ) ;
233+ } ) ;
160234} ) ;
0 commit comments