File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ public static Policy ToPolicy(PolicyRequest[] policyRequests)
139139 Action = new string [ ] { "s3:*" } ,
140140 Effect = "Allow" ,
141141 Resource = policyRequests
142- . Select ( pr => System . IO . Path . Join ( pr . BucketName , pr . FolderName , "*" ) )
142+ . Select ( pr => $ " { pr . BucketName } / { pr . FolderName } /*" )
143143 . Distinct ( )
144144 . ToArray ( ) ,
145145 } ,
Original file line number Diff line number Diff line change 1414 * limitations under the License.
1515 */
1616
17+ using Monai . Deploy . Storage . S3Policy . Policies ;
1718using Newtonsoft . Json ;
1819
1920namespace Monai . Deploy . Storage . S3Policy . Tests . Extensions
@@ -100,6 +101,22 @@ public void ToPolicy_NullFolder_ThrowsException()
100101 Assert . Throws < ArgumentNullException > ( ( ) => PolicyExtensions . ToPolicy ( "test-bucket" , null ) ) ;
101102 }
102103
104+ [ Fact ]
105+ public async Task ToPolicy_Should_Set_Correct_Allow_All_Path ( )
106+ {
107+ const string bucketName = "test-bucket" ;
108+ const string payloadId = "00000000-1000-0000-0000-000000000000" ;
109+
110+ var policys = new PolicyRequest [ ] { new PolicyRequest ( bucketName , payloadId ) } ;
111+
112+ var policyMade = PolicyExtensions . ToPolicy ( policys ) ;
113+
114+ Assert . EndsWith (
115+ $ "{ bucketName } /{ payloadId } /*",
116+ policyMade . Statement . First ( p => p . Sid == "AllowAllS3ActionsInUserFolder" ) . Resource ? . First ( ) ) ;
117+
118+ }
119+
103120 #endregion ToPolicy
104121 }
105122}
You can’t perform that action at this time.
0 commit comments