2828import com .google .cloud .conformance .storage .v1 .UrlStyle ;
2929import com .google .cloud .storage .testing .RemoteStorageHelper ;
3030import com .google .common .base .Charsets ;
31- import com .google .common .base .Strings ;
3231import com .google .common .io .BaseEncoding ;
3332import com .google .protobuf .Timestamp ;
3433import com .google .protobuf .util .JsonFormat ;
@@ -117,17 +116,6 @@ public void test() {
117116
118117 PolicyConditions conditions = policyInput .getConditions ();
119118
120- if (!Strings .isNullOrEmpty (fields .get ("success_action_redirect" ))) {
121- builder .addSuccessActionRedirectUrlCondition (
122- PostPolicyV4 .ConditionV4Type .MATCHES , fields .get ("success_action_redirect" ));
123- }
124-
125- if (!Strings .isNullOrEmpty (fields .get ("success_action_status" ))) {
126- builder .addSuccessActionStatusCondition (
127- PostPolicyV4 .ConditionV4Type .MATCHES ,
128- Integer .parseInt (fields .get ("success_action_status" )));
129- }
130-
131119 if (conditions != null ) {
132120 if (!conditions .getStartsWithList ().isEmpty ()) {
133121 builder .addCustomCondition (
@@ -166,17 +154,25 @@ public void test() {
166154 style );
167155
168156 String expectedPolicy = testData .getPolicyOutput ().getExpectedDecodedPolicy ();
157+
169158 StringBuilder escapedPolicy = new StringBuilder ();
170159
171160 // Java automatically unescapes the unicode escapes in the conformance tests, so we need to
172161 // manually re-escape them
173- for (char c : expectedPolicy .toCharArray ()) {
162+ char [] expectedPolicyArray = expectedPolicy .toCharArray ();
163+ for (int i = 0 ; i < expectedPolicyArray .length ; i ++) {
164+ char c = expectedPolicyArray [i ];
174165 if (c >= 128 ) {
175166 escapedPolicy .append (String .format ("\\ u%04x" , (int ) c ));
176167 } else {
177168 switch (c ) {
178169 case '\\' :
179- escapedPolicy .append ("\\ \\ " );
170+ // quotes aren't unescaped, so leave any "\"" found alone
171+ if (expectedPolicyArray [i + 1 ] == '"' ) {
172+ escapedPolicy .append ("\\ " );
173+ } else {
174+ escapedPolicy .append ("\\ \\ " );
175+ }
180176 break ;
181177 case '\b' :
182178 escapedPolicy .append ("\\ b" );
@@ -202,6 +198,7 @@ public void test() {
202198 }
203199 }
204200 assertEquals (testData .getPolicyOutput ().getFieldsMap (), policy .getFields ());
201+
205202 assertEquals (
206203 escapedPolicy .toString (),
207204 new String (BaseEncoding .base64 ().decode (policy .getFields ().get ("policy" ))));
0 commit comments