Skip to content

Commit 0f358b6

Browse files
committed
tests and fixies
Signed-off-by: Dmitrii Tikhomirov <[email protected]>
1 parent 6f56995 commit 0f358b6

24 files changed

+1038
-62
lines changed

impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/AccessTokenProvider.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.serverlessworkflow.impl.executors.http.oauth;
1817

1918
import io.serverlessworkflow.http.jwt.JWT;

impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/ClientSecretBasic.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.serverlessworkflow.impl.executors.http.oauth;
1817

1918
import static io.serverlessworkflow.api.types.OAuth2AutenthicationData.OAuth2AutenthicationDataGrant.CLIENT_CREDENTIALS;

impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/ClientSecretPostStep.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.serverlessworkflow.impl.executors.http.oauth;
1817

1918
import static io.serverlessworkflow.api.types.OAuth2AutenthicationData.OAuth2AutenthicationDataGrant.CLIENT_CREDENTIALS;

impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/HttpRequestBuilder.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.serverlessworkflow.impl.executors.http.oauth;
1817

1918
import static io.serverlessworkflow.api.types.OAuth2TokenRequest.Oauth2TokenRequestEncoding;
@@ -35,8 +34,6 @@
3534
import jakarta.ws.rs.core.Form;
3635
import jakarta.ws.rs.core.MediaType;
3736
import java.net.URI;
38-
import java.net.URLEncoder;
39-
import java.nio.charset.StandardCharsets;
4037
import java.util.HashMap;
4138
import java.util.Map;
4239
import java.util.Objects;
@@ -115,21 +112,17 @@ InvocationHolder build(WorkflowContext workflow, TaskContext task, WorkflowModel
115112
form.param("grant_type", grantType.value());
116113
queryParams.forEach(
117114
(key, value) -> {
118-
String v = value.apply(workflow, task, model);
119-
String encodedKey = URLEncoder.encode(key, StandardCharsets.UTF_8);
120-
String encodedValue = URLEncoder.encode(v, StandardCharsets.UTF_8);
121-
form.param(encodedKey, encodedValue);
115+
String resolved = value.apply(workflow, task, model);
116+
form.param(key, resolved);
122117
});
123118
entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED);
124119
} else {
125120
Map<String, Object> jsonData = new HashMap<>();
126121
jsonData.put("grant_type", grantType.value());
127122
queryParams.forEach(
128123
(key, value) -> {
129-
String v = value.apply(workflow, task, model);
130-
String encodedKey = URLEncoder.encode(key, StandardCharsets.UTF_8);
131-
String encodedValue = URLEncoder.encode(v, StandardCharsets.UTF_8);
132-
jsonData.put(encodedKey, encodedValue);
124+
String resolved = value.apply(workflow, task, model);
125+
jsonData.put(key, resolved);
133126
});
134127
entity = Entity.entity(jsonData, MediaType.APPLICATION_JSON);
135128
}

impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/InvocationHolder.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.serverlessworkflow.impl.executors.http.oauth;
1817

1918
import jakarta.ws.rs.client.Client;

impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/OAuthRequestBuilder.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.serverlessworkflow.impl.executors.http.oauth;
1817

1918
import static io.serverlessworkflow.api.types.OAuth2AutenthicationDataClient.ClientAuthentication.CLIENT_SECRET_POST;
@@ -27,8 +26,11 @@
2726
import io.serverlessworkflow.impl.WorkflowContext;
2827
import io.serverlessworkflow.impl.WorkflowModel;
2928
import java.net.URI;
29+
import java.util.Arrays;
3030
import java.util.List;
3131
import java.util.Map;
32+
import java.util.Objects;
33+
import java.util.stream.Collectors;
3234

3335
public class OAuthRequestBuilder {
3436

@@ -112,9 +114,21 @@ public void audience(HttpRequestBuilder requestBuilder) {
112114
}
113115

114116
private void scope(HttpRequestBuilder requestBuilder) {
115-
if (authenticationData.getScopes() != null && !authenticationData.getScopes().isEmpty()) {
116-
String scopes = String.join(" ", authenticationData.getScopes());
117-
requestBuilder.addQueryParam("scope", scopes);
117+
List<String> scopesList = authenticationData.getScopes();
118+
if (scopesList == null || scopesList.isEmpty()) {
119+
return;
120+
}
121+
String scope =
122+
scopesList.stream()
123+
.filter(Objects::nonNull)
124+
.map(String::trim)
125+
.filter(s -> !s.isEmpty())
126+
.flatMap(s -> Arrays.stream(s.split("\\s+")))
127+
.distinct()
128+
.collect(Collectors.joining(" "));
129+
130+
if (!scope.isEmpty()) {
131+
requestBuilder.addQueryParam("scope", scope);
118132
}
119133
}
120134

impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/TokenResponseHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.serverlessworkflow.impl.executors.http.oauth;
1817

1918
import io.serverlessworkflow.impl.TaskContext;

0 commit comments

Comments
 (0)