-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(soap): adds additional script method and configuration property …
…to return a fault.
- Loading branch information
1 parent
32d5e34
commit 6725f31
Showing
12 changed files
with
277 additions
and
19 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
62 changes: 62 additions & 0 deletions
62
mock/soap/src/main/java/io/gatehill/imposter/plugin/soap/config/SoapResponseConfig.kt
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,62 @@ | ||
/* | ||
* Copyright (c) 2016-2021. | ||
* | ||
* This file is part of Imposter. | ||
* | ||
* "Commons Clause" License Condition v1.0 | ||
* | ||
* The Software is provided to you by the Licensor under the License, as | ||
* defined below, subject to the following condition. | ||
* | ||
* Without limiting other conditions in the License, the grant of rights | ||
* under the License will not include, and the License does not grant to | ||
* you, the right to Sell the Software. | ||
* | ||
* For purposes of the foregoing, "Sell" means practicing any or all of | ||
* the rights granted to you under the License to provide to third parties, | ||
* for a fee or other consideration (including without limitation fees for | ||
* hosting or consulting/support services related to the Software), a | ||
* product or service whose value derives, entirely or substantially, from | ||
* the functionality of the Software. Any license notice or attribution | ||
* required by the License must also include this Commons Clause License | ||
* Condition notice. | ||
* | ||
* Software: Imposter | ||
* | ||
* License: GNU Lesser General Public License version 3 | ||
* | ||
* Licensor: Peter Cornish | ||
* | ||
* Imposter is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Imposter is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Imposter. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package io.gatehill.imposter.plugin.soap.config | ||
|
||
import io.gatehill.imposter.plugin.config.resource.ResponseConfig | ||
|
||
/** | ||
* Extends the base response configuration with items specific | ||
* to the OpenAPI plugin. | ||
* | ||
* @author Pete Cornish | ||
*/ | ||
class SoapResponseConfig : ResponseConfig() { | ||
val soapFault: Boolean? = null | ||
|
||
override fun hasConfiguration(): Boolean = | ||
super.hasConfiguration() || null != soapFault | ||
|
||
override fun toString(): String { | ||
return "OpenApiResponseConfig(parent=${super.toString()}, soapFault=$soapFault)" | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
.../soap/src/main/java/io/gatehill/imposter/plugin/soap/http/SoapResponseBehaviourFactory.kt
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,70 @@ | ||
/* | ||
* Copyright (c) 2016-2021. | ||
* | ||
* This file is part of Imposter. | ||
* | ||
* "Commons Clause" License Condition v1.0 | ||
* | ||
* The Software is provided to you by the Licensor under the License, as | ||
* defined below, subject to the following condition. | ||
* | ||
* Without limiting other conditions in the License, the grant of rights | ||
* under the License will not include, and the License does not grant to | ||
* you, the right to Sell the Software. | ||
* | ||
* For purposes of the foregoing, "Sell" means practicing any or all of | ||
* the rights granted to you under the License to provide to third parties, | ||
* for a fee or other consideration (including without limitation fees for | ||
* hosting or consulting/support services related to the Software), a | ||
* product or service whose value derives, entirely or substantially, from | ||
* the functionality of the Software. Any license notice or attribution | ||
* required by the License must also include this Commons Clause License | ||
* Condition notice. | ||
* | ||
* Software: Imposter | ||
* | ||
* License: GNU Lesser General Public License version 3 | ||
* | ||
* Licensor: Peter Cornish | ||
* | ||
* Imposter is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Imposter is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Imposter. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package io.gatehill.imposter.plugin.soap.http | ||
|
||
import io.gatehill.imposter.http.DefaultResponseBehaviourFactory | ||
import io.gatehill.imposter.plugin.config.resource.BasicResourceConfig | ||
import io.gatehill.imposter.plugin.soap.config.SoapResponseConfig | ||
import io.gatehill.imposter.script.ReadWriteResponseBehaviour | ||
|
||
/** | ||
* Extends base response behaviour population with specific | ||
* SOAP plugin configuration. | ||
* | ||
* @author Pete Cornish | ||
*/ | ||
class SoapResponseBehaviourFactory : DefaultResponseBehaviourFactory() { | ||
override fun populate( | ||
statusCode: Int, | ||
resourceConfig: BasicResourceConfig, | ||
responseBehaviour: ReadWriteResponseBehaviour | ||
) { | ||
if ((resourceConfig.responseConfig as SoapResponseConfig).soapFault == true) { | ||
responseBehaviour.withSoapFault() | ||
} | ||
|
||
// invoke superclass after calling `withSoapFault` as it | ||
// overrides the status code to 500 | ||
super.populate(statusCode, resourceConfig, responseBehaviour) | ||
} | ||
} |
Oops, something went wrong.