Merge pull request #440 from andreisavu/1.4.x-decode-key

Decode both the key and the value when parsing the request URI
This commit is contained in:
Andrei Savu 2012-03-14 13:56:58 -07:00
commit fc58a77381
3 changed files with 10 additions and 4 deletions

View File

@ -231,9 +231,7 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
@Override
public boolean apply(@Nullable Network network) {
return network.isDefault() &&
network.getGuestIPType() == GuestIPType.VIRTUAL &&
network.getNetworkOfferingId() == 6 &&
network.getId() == 204;
network.getGuestIPType() == GuestIPType.VIRTUAL;
}
}));
logger.info("Required network: " + requiredNetwork);

View File

@ -170,7 +170,7 @@ public class ModifyRequest {
int indexOfFirstEquals = stringToParse.indexOf('=');
String key = indexOfFirstEquals == -1 ? stringToParse : stringToParse.substring(0, indexOfFirstEquals);
String value = indexOfFirstEquals == -1 ? null : stringToParse.substring(indexOfFirstEquals + 1);
map.put(key, Strings2.urlDecode(value));
map.put(Strings2.urlDecode(key), Strings2.urlDecode(value));
}
public static String makeQueryLine(Multimap<String, String> params,

View File

@ -147,4 +147,12 @@ public class ModifyRequestTest {
assertEquals(parsedMap.get("publickey"), expected);
}
@Test
public void testParseQueryWithKeysThatRequireDecoding() {
Multimap<String, String> parsedMap = parseQueryToMap("network%5B0%5D.id=23&network%5B0%5D.address=192.168.0.1");
assertEquals(parsedMap.get("network[0].id"), ImmutableSet.of("23"));
assertEquals(parsedMap.get("network[0].address"), ImmutableSet.of("192.168.0.1"));
}
}