-
-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: IndexOutOfBoundsException when query param without value #1788
- Loading branch information
1 parent
ab90ca3
commit a311746
Showing
13 changed files
with
128 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
core/model/src/test/groovy/au/com/dius/pact/core/model/BaseRequestSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package au.com.dius.pact.core.model | ||
|
||
import au.com.dius.pact.core.support.json.JsonParser | ||
import au.com.dius.pact.core.support.json.JsonValue | ||
import spock.lang.Specification | ||
|
||
class BaseRequestSpec extends Specification { | ||
def 'parseQueryParametersToMap'() { | ||
expect: | ||
BaseRequest.parseQueryParametersToMap(json) == value | ||
|
||
where: | ||
|
||
json | value | ||
null | [:] | ||
JsonValue.Null.INSTANCE | [:] | ||
JsonValue.True.INSTANCE | [:] | ||
JsonValue.False.INSTANCE | [:] | ||
new JsonValue.Integer(100) | [:] | ||
new JsonValue.Decimal(100.0) | [:] | ||
new JsonValue.Array([]) | [:] | ||
new JsonValue.StringValue('a=1&b=2') | [a: ['1'], b: ['2']] | ||
} | ||
|
||
def 'parseQueryParametersToMap - with a JSON map'() { | ||
expect: | ||
BaseRequest.parseQueryParametersToMap(JsonParser.parseString(json).asObject()) == value | ||
|
||
where: | ||
|
||
json | value | ||
'{}' | [:] | ||
'{"a": "1"}' | [a: ['1']] | ||
'{"a": ["1"]}' | [a: ['1']] | ||
'{"a": ["", ""]}' | [a: ['', '']] | ||
'{"a": [null, ""]}' | [a: [null, '']] | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
core/model/src/test/groovy/au/com/dius/pact/core/model/PactReaderKtSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package au.com.dius.pact.core.model | ||
|
||
import spock.lang.Issue | ||
import spock.lang.Specification | ||
|
||
import static au.com.dius.pact.core.model.PactReaderKt.queryStringToMap | ||
|
||
class PactReaderKtSpec extends Specification { | ||
def 'parsing a query string'() { | ||
expect: | ||
queryStringToMap(query) == result | ||
|
||
where: | ||
|
||
query | result | ||
null | [:] | ||
'' | [:] | ||
'p=1' | [p: ['1']] | ||
'p=1&q=2' | [p: ['1'], q: ['2']] | ||
'p=1&q=2&p=3' | [p: ['1', '3'], q: ['2']] | ||
'p=1&q=2=&p=3' | [p: ['1', '3'], q: ['2=']] | ||
'&&' | [:] | ||
} | ||
|
||
@Issue('#1788') | ||
def 'parsing a query string with empty or missing values'() { | ||
expect: | ||
queryStringToMap(query) == result | ||
|
||
where: | ||
|
||
query | result | ||
'p=' | [p: ['']] | ||
'p=1&q=&p=3' | [p: ['1', '3'], q: ['']] | ||
'p&q=1&q=2' | [p: [null], q: ['1', '2']] | ||
'p&p&p' | [p: [null, null, null]] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters