@@ -5,15 +5,39 @@ const getReplicationInfo =
55 require ( '../../../../lib/api/apiUtils/object/getReplicationInfo' ) ;
66const { makeAuthInfo } = require ( '../../helpers' ) ;
77
8- function _getObjectReplicationInfo ( replicationConfig , authInfo , isDeleteMarker ) {
8+ function _getObjectReplicationInfo ( replicationEndpoints , replicationConfig , authInfo , isDeleteMarker ) {
99 const bucketInfo = new BucketInfo (
1010 'testbucket' , 'someCanonicalId' , 'accountDisplayName' ,
1111 new Date ( ) . toJSON ( ) ,
1212 null , null , null , null , null , null , null , null , null ,
1313 replicationConfig ) ;
14- return getReplicationInfo ( 'fookey' , bucketInfo , true , 123 , null , null , authInfo , isDeleteMarker ) ;
14+ return getReplicationInfo ( replicationEndpoints ,
15+ 'fookey' , bucketInfo , true , 123 , null , null , authInfo , isDeleteMarker ) ;
1516}
1617
18+ const TEST_CONFIG = {
19+ locationConstraints : {
20+ awsbackend : {
21+ type : 'aws_s3' ,
22+ legacyAwsBehavior : true ,
23+ details : {
24+ awsEndpoint : 's3.amazonaws.com' ,
25+ bucketName : 'multitester555' ,
26+ bucketMatch : true ,
27+ credentialsProfile : 'default' ,
28+ } ,
29+ } ,
30+ } ,
31+ replicationEndpoints : [ {
32+ site : 'zenko' ,
33+ servers : [ '127.0.0.1:8000' ] ,
34+ default : true ,
35+ } , {
36+ site : 'us-east-2' ,
37+ type : 'aws_s3' ,
38+ } ] ,
39+ } ;
40+
1741describe ( 'getReplicationInfo helper' , ( ) => {
1842 it ( 'should get replication info when rules are enabled' , ( ) => {
1943 const replicationConfig = {
@@ -25,7 +49,7 @@ describe('getReplicationInfo helper', () => {
2549 } ] ,
2650 destination : 'tosomewhere' ,
2751 } ;
28- const replicationInfo = _getObjectReplicationInfo ( replicationConfig ) ;
52+ const replicationInfo = _getObjectReplicationInfo ( TEST_CONFIG , replicationConfig ) ;
2953 assert . deepStrictEqual ( replicationInfo , {
3054 status : 'PENDING' ,
3155 backends : [ {
@@ -53,7 +77,8 @@ describe('getReplicationInfo helper', () => {
5377 } ;
5478
5579 const authInfo = makeAuthInfo ( 'accessKey1' , null , 'another-session' ) ;
56- const replicationInfo = _getObjectReplicationInfo ( replicationConfig , authInfo , true ) ;
80+ const replicationInfo = _getObjectReplicationInfo ( TEST_CONFIG ,
81+ replicationConfig , authInfo , true ) ;
5782
5883 assert . deepStrictEqual ( replicationInfo , {
5984 status : 'PENDING' ,
@@ -83,7 +108,8 @@ describe('getReplicationInfo helper', () => {
83108 } ;
84109
85110 const authInfo = makeAuthInfo ( 'accessKey1' , null , 'backbeat-lifecycle' ) ;
86- const replicationInfo = _getObjectReplicationInfo ( replicationConfig , authInfo , false ) ;
111+ const replicationInfo = _getObjectReplicationInfo ( TEST_CONFIG ,
112+ replicationConfig , authInfo , false ) ;
87113
88114 assert . deepStrictEqual ( replicationInfo , {
89115 status : 'PENDING' ,
@@ -110,11 +136,11 @@ describe('getReplicationInfo helper', () => {
110136 } ] ,
111137 destination : 'tosomewhere' ,
112138 } ;
113- const replicationInfo = _getObjectReplicationInfo ( replicationConfig ) ;
139+ const replicationInfo = _getObjectReplicationInfo ( TEST_CONFIG , replicationConfig ) ;
114140 assert . deepStrictEqual ( replicationInfo , undefined ) ;
115141 } ) ;
116142
117- it ( 'should not get replication info when action comming from lifecycle session' , ( ) => {
143+ it ( 'should not get replication info when action coming from lifecycle session' , ( ) => {
118144 const replicationConfig = {
119145 role : 'arn:aws:iam::root:role/s3-replication-role' ,
120146 rules : [ {
@@ -126,7 +152,8 @@ describe('getReplicationInfo helper', () => {
126152 } ;
127153
128154 const authInfo = makeAuthInfo ( 'accessKey1' , null , 'backbeat-lifecycle' ) ;
129- const replicationInfo = _getObjectReplicationInfo ( replicationConfig , authInfo , true ) ;
155+ const replicationInfo = _getObjectReplicationInfo ( TEST_CONFIG ,
156+ replicationConfig , authInfo , true ) ;
130157
131158 assert . deepStrictEqual ( replicationInfo , undefined ) ;
132159 } ) ;
0 commit comments