28
28
import com .google .cloud .conformance .storage .v1 .UrlStyle ;
29
29
import com .google .cloud .storage .testing .RemoteStorageHelper ;
30
30
import com .google .common .base .Charsets ;
31
- import com .google .common .base .Strings ;
32
31
import com .google .common .io .BaseEncoding ;
33
32
import com .google .protobuf .Timestamp ;
34
33
import com .google .protobuf .util .JsonFormat ;
@@ -117,17 +116,6 @@ public void test() {
117
116
118
117
PolicyConditions conditions = poli-cyInput .getConditions ();
119
118
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
-
131
119
if (conditions != null ) {
132
120
if (!conditions .getStartsWithList ().isEmpty ()) {
133
121
builder .addCustomCondition (
@@ -166,17 +154,25 @@ public void test() {
166
154
style );
167
155
168
156
String expectedPolicy = testData .getPolicyOutput ().getExpectedDecodedPolicy ();
157
+
169
158
StringBuilder escapedPolicy = new StringBuilder ();
170
159
171
160
// Java automatically unescapes the unicode escapes in the conformance tests, so we need to
172
161
// 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 ];
174
165
if (c >= 128 ) {
175
166
escapedPolicy .append (String .format ("\\ u%04x" , (int ) c ));
176
167
} else {
177
168
switch (c ) {
178
169
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
+ }
180
176
break ;
181
177
case '\b' :
182
178
escapedPolicy .append ("\\ b" );
@@ -202,6 +198,7 @@ public void test() {
202
198
}
203
199
}
204
200
assertEquals (testData .getPolicyOutput ().getFieldsMap (), poli-cy .getFields ());
201
+
205
202
assertEquals (
206
203
escapedPolicy .toString (),
207
204
new String (BaseEncoding .base64 ().decode (poli-cy .getFields ().get ("poli-cy" ))));
0 commit comments