cloudbridge compatibility glitch on AuthError

This commit is contained in:
Adrian Cole 2012-06-15 14:32:45 -04:00
parent 71869a6bb3
commit e0a5ffbe9a
2 changed files with 7 additions and 1 deletions

View File

@ -112,7 +112,7 @@ public class ParseAWSErrorFromXmlContent implements HttpErrorHandler {
".InUse")))
|| (message != null && (message.indexOf("already exists") != -1 || message.indexOf("is in use") != -1)))
exception = new IllegalStateException(message, exception);
else if ("AuthFailure".equals(errorCode))
else if (errorCode != null && errorCode.indexOf("AuthFailure") != -1)
exception = new AuthorizationException(message, exception);
else if (message != null
&& (message.indexOf("Invalid id") != -1 || message.indexOf("Failed to bind") != -1))

View File

@ -164,6 +164,12 @@ public class ParseAWSErrorFromXmlContentTest {
"<Error><Code>AuthFailure</Code></Error>", AuthorizationException.class);
}
@Test
public void test400WithCloudBridgeAuthFailureSetsAuthorizationException() {
assertCodeMakes("GET", URI.create("https://amazonaws.com/foo"), 400, "",
"<Error><Code>Client.AuthFailure</Code></Error>", AuthorizationException.class);
}
private void assertCodeMakes(String method, URI uri, int statusCode, String message, String content,
Class<? extends Exception> expected) {
assertCodeMakes(method, uri, statusCode, message, "text/xml", content, expected);