diff --git a/sdks/backend/java/component-api/src/main/java/com/bytechef/component/definition/Authorization.java b/sdks/backend/java/component-api/src/main/java/com/bytechef/component/definition/Authorization.java index ff1bee3a031..0b63a661e96 100644 --- a/sdks/backend/java/component-api/src/main/java/com/bytechef/component/definition/Authorization.java +++ b/sdks/backend/java/component-api/src/main/java/com/bytechef/component/definition/Authorization.java @@ -20,6 +20,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; /** @@ -193,6 +194,30 @@ enum AuthorizationType { public String getName() { return name().toLowerCase(); } + + /** + * Returns true if value converts to valid authorisation type enumeration. NONE is not valid type as it should + * signal absence of authorisation mechanism. + * + * @param value authorisation name + * @return false if value converts to NONE or value does not mach any of enumeration names, otherwise returns + * true + */ + public static boolean isApplicable(String value) { + if (value == null) { + return false; + } + + for (AuthorizationType authorizationType : values()) { + String name = authorizationType.getName(); + + if ((authorizationType != NONE) && Objects.equals(value.toLowerCase(), name.toLowerCase())) { + return true; + } + } + + return false; + } } /** diff --git a/sdks/backend/java/component-api/src/test/java/com/bytechef/component/definition/AuthorizationTest.java b/sdks/backend/java/component-api/src/test/java/com/bytechef/component/definition/AuthorizationTest.java new file mode 100644 index 00000000000..5264f0c8d8c --- /dev/null +++ b/sdks/backend/java/component-api/src/test/java/com/bytechef/component/definition/AuthorizationTest.java @@ -0,0 +1,108 @@ +/* + * Copyright 2023-present ByteChef Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.bytechef.component.definition; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * @author Igor Beslic + */ +public class AuthorizationTest { + + @Test + public void testAuthorizationAuthorizationTypeIsApplicable() { + + for (String applicableValue : getRandomApplicableValues()) { + Assertions.assertTrue( + Authorization.AuthorizationType.isApplicable(applicableValue), applicableValue + " is valid"); + } + + for (String nonApplicableValue : getRandomNonApplicableValues()) { + Assertions.assertFalse( + Authorization.AuthorizationType.isApplicable(nonApplicableValue), nonApplicableValue + " is valid"); + } + + } + + private static Random random = new Random(); + + private List getRandomApplicableValues() { + Authorization.AuthorizationType[] values = Authorization.AuthorizationType.values(); + + List names = new ArrayList<>(); + + for (Authorization.AuthorizationType value : values) { + if (value == Authorization.AuthorizationType.NONE) { + continue; + } + + String name = value.getName(); + + if (random.nextBoolean()) { + names.add(name.toLowerCase()); + + continue; + } + + if (random.nextBoolean()) { + char charToReplace = name.charAt(random.nextInt(name.length())); + + if (charToReplace == 95) { + continue; + } + + names.add(name.replace(charToReplace, (char) (charToReplace - 32))); + + continue; + } + + names.add(name); + + } + + return names; + } + + private List getRandomNonApplicableValues() { + List randomApplicableValues = getRandomApplicableValues(); + + List nonApplicableValues = new ArrayList<>(); + + for (String randomApplicableValue : randomApplicableValues) { + nonApplicableValues.add(randomApplicableValue + "_wrong"); + } + + nonApplicableValues.add("none"); + nonApplicableValues.add("None"); + nonApplicableValues.add("nOne"); + nonApplicableValues.add("noNe"); + nonApplicableValues.add("nonE"); + nonApplicableValues.add("NonE"); + nonApplicableValues.add("nOnE"); + nonApplicableValues.add("noNE"); + nonApplicableValues.add("NoNE"); + nonApplicableValues.add("nONE"); + nonApplicableValues.add("NONE"); + + return nonApplicableValues; + } + +} diff --git a/server/libs/modules/components/http-client/src/main/java/com/bytechef/component/http/client/connection/HttpClientConnection.java b/server/libs/modules/components/http-client/src/main/java/com/bytechef/component/http/client/connection/HttpClientConnection.java index 3888eba20cf..98507a81648 100644 --- a/server/libs/modules/components/http-client/src/main/java/com/bytechef/component/http/client/connection/HttpClientConnection.java +++ b/server/libs/modules/components/http-client/src/main/java/com/bytechef/component/http/client/connection/HttpClientConnection.java @@ -41,7 +41,8 @@ public class HttpClientConnection { public static final ModifiableConnectionDefinition CONNECTION_DEFINITION = connection() - .properties(string(BASE_URI).label("Base URI")) + .properties(string(BASE_URI).label("Base URI") + .description("If set, it will be combined HTTP Client Component URI attribute value.")) .authorizationRequired(false) .authorizations( authorization(Authorization.AuthorizationType.API_KEY) diff --git a/server/libs/modules/components/http-client/src/main/java/com/bytechef/component/http/client/constant/HttpClientComponentConstants.java b/server/libs/modules/components/http-client/src/main/java/com/bytechef/component/http/client/constant/HttpClientComponentConstants.java index 7f25bfca9f2..52ca316b249 100644 --- a/server/libs/modules/components/http-client/src/main/java/com/bytechef/component/http/client/constant/HttpClientComponentConstants.java +++ b/server/libs/modules/components/http-client/src/main/java/com/bytechef/component/http/client/constant/HttpClientComponentConstants.java @@ -107,7 +107,9 @@ public class HttpClientComponentConstants { string(URI) .label("URI") - .description("The URI to make the request to") + .description( + "The URI to make the request to. If HTTP Client Connection defines Base URI, then this value is appended to it.") + .exampleValue("/") .placeholder("https://example.com/index.html") .defaultValue("") .required(true), diff --git a/server/libs/modules/components/http-client/src/test/resources/definition/http-client_v1.json b/server/libs/modules/components/http-client/src/test/resources/definition/http-client_v1.json index 35a9987966c..b900a9c910b 100644 --- a/server/libs/modules/components/http-client/src/test/resources/definition/http-client_v1.json +++ b/server/libs/modules/components/http-client/src/test/resources/definition/http-client_v1.json @@ -93,16 +93,16 @@ "acquire" : null, "authorizationCallback" : null, "oauth2AuthorizationExtraQueryParameters" : null, + "authorizationUrl" : null, + "clientSecret" : null, + "refreshToken" : null, "apply" : null, "clientId" : null, "pkce" : null, "refresh" : null, "refreshUrl" : null, "scopes" : null, - "tokenUrl" : null, - "authorizationUrl" : null, - "clientSecret" : null, - "refreshToken" : null + "tokenUrl" : null }, { "detectOn" : null, "description" : null, @@ -134,16 +134,16 @@ "acquire" : null, "authorizationCallback" : null, "oauth2AuthorizationExtraQueryParameters" : null, + "authorizationUrl" : null, + "clientSecret" : null, + "refreshToken" : null, "apply" : null, "clientId" : null, "pkce" : null, "refresh" : null, "refreshUrl" : null, "scopes" : null, - "tokenUrl" : null, - "authorizationUrl" : null, - "clientSecret" : null, - "refreshToken" : null + "tokenUrl" : null }, { "detectOn" : null, "description" : null, @@ -195,16 +195,16 @@ "acquire" : null, "authorizationCallback" : null, "oauth2AuthorizationExtraQueryParameters" : null, + "authorizationUrl" : null, + "clientSecret" : null, + "refreshToken" : null, "apply" : null, "clientId" : null, "pkce" : null, "refresh" : null, "refreshUrl" : null, "scopes" : null, - "tokenUrl" : null, - "authorizationUrl" : null, - "clientSecret" : null, - "refreshToken" : null + "tokenUrl" : null }, { "detectOn" : null, "description" : null, @@ -256,16 +256,16 @@ "acquire" : null, "authorizationCallback" : null, "oauth2AuthorizationExtraQueryParameters" : null, + "authorizationUrl" : null, + "clientSecret" : null, + "refreshToken" : null, "apply" : null, "clientId" : null, "pkce" : null, "refresh" : null, "refreshUrl" : null, "scopes" : null, - "tokenUrl" : null, - "authorizationUrl" : null, - "clientSecret" : null, - "refreshToken" : null + "tokenUrl" : null }, { "detectOn" : null, "description" : null, @@ -397,16 +397,16 @@ "acquire" : null, "authorizationCallback" : null, "oauth2AuthorizationExtraQueryParameters" : null, + "authorizationUrl" : null, + "clientSecret" : null, + "refreshToken" : null, "apply" : null, "clientId" : null, "pkce" : null, "refresh" : null, "refreshUrl" : null, "scopes" : null, - "tokenUrl" : null, - "authorizationUrl" : null, - "clientSecret" : null, - "refreshToken" : null + "tokenUrl" : null }, { "detectOn" : null, "description" : null, @@ -518,16 +518,16 @@ "acquire" : null, "authorizationCallback" : null, "oauth2AuthorizationExtraQueryParameters" : null, + "authorizationUrl" : null, + "clientSecret" : null, + "refreshToken" : null, "apply" : null, "clientId" : null, "pkce" : null, "refresh" : null, "refreshUrl" : null, "scopes" : null, - "tokenUrl" : null, - "authorizationUrl" : null, - "clientSecret" : null, - "refreshToken" : null + "tokenUrl" : null }, { "detectOn" : null, "description" : null, @@ -639,20 +639,20 @@ "acquire" : null, "authorizationCallback" : null, "oauth2AuthorizationExtraQueryParameters" : null, + "authorizationUrl" : null, + "clientSecret" : null, + "refreshToken" : null, "apply" : null, "clientId" : null, "pkce" : null, "refresh" : null, "refreshUrl" : null, "scopes" : null, - "tokenUrl" : null, - "authorizationUrl" : null, - "clientSecret" : null, - "refreshToken" : null + "tokenUrl" : null } ], "properties" : [ { "advancedOption" : null, - "description" : null, + "description" : "If set, it will be combined HTTP Client Component URI attribute value.", "displayCondition" : null, "expressionEnabled" : null, "hidden" : null, @@ -691,7 +691,7 @@ }, "properties" : [ { "advancedOption" : null, - "description" : "The URI to make the request to", + "description" : "The URI to make the request to. If HTTP Client Connection defines Base URI, then this value is appended to it.", "displayCondition" : null, "expressionEnabled" : null, "hidden" : null, @@ -700,7 +700,7 @@ "name" : "uri", "type" : "STRING", "defaultValue" : "", - "exampleValue" : null, + "exampleValue" : "/", "label" : "URI", "placeholder" : "https://example.com/index.html", "controlType" : "TEXT", @@ -842,14 +842,14 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : null, "description" : "Query parameters to send.", @@ -903,14 +903,14 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Returns the full response data instead of only the body.", @@ -1044,8 +1044,8 @@ "maxValue" : null, "minValue" : 1, "options" : null, - "controlType" : "INTEGER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "INTEGER" } ], "title" : "GET", "processErrorResponse" : null, @@ -1066,7 +1066,7 @@ }, "properties" : [ { "advancedOption" : null, - "description" : "The URI to make the request to", + "description" : "The URI to make the request to. If HTTP Client Connection defines Base URI, then this value is appended to it.", "displayCondition" : null, "expressionEnabled" : null, "hidden" : null, @@ -1075,7 +1075,7 @@ "name" : "uri", "type" : "STRING", "defaultValue" : "", - "exampleValue" : null, + "exampleValue" : "/", "label" : "URI", "placeholder" : "https://example.com/index.html", "controlType" : "TEXT", @@ -1217,14 +1217,14 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : null, "description" : "Query parameters to send.", @@ -1278,14 +1278,14 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Content-Type to use when sending body parameters.", @@ -1367,8 +1367,8 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" }, { "advancedOption" : null, "description" : null, @@ -1408,8 +1408,8 @@ "label" : null, "placeholder" : null, "options" : null, - "controlType" : "DATE", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "DATE" }, { "advancedOption" : null, "description" : null, @@ -1425,8 +1425,8 @@ "label" : null, "placeholder" : null, "options" : null, - "controlType" : "DATE_TIME", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "DATE_TIME" }, { "advancedOption" : null, "description" : null, @@ -1444,8 +1444,8 @@ "maxValue" : null, "minValue" : null, "options" : null, - "controlType" : "INTEGER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "INTEGER" }, { "advancedOption" : null, "description" : null, @@ -1481,8 +1481,8 @@ "minValue" : null, "numberPrecision" : null, "options" : null, - "controlType" : "NUMBER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "NUMBER" }, { "advancedOption" : null, "description" : null, @@ -1501,8 +1501,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : null, "description" : null, @@ -1538,14 +1538,14 @@ "label" : null, "placeholder" : null, "options" : null, - "controlType" : "TIME", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "TIME" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "XML content to send.", @@ -1564,8 +1564,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Body parameters to send.", @@ -1700,8 +1700,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Body parameters to send.", @@ -1740,8 +1740,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "The raw text to send.", @@ -2011,8 +2011,8 @@ "maxValue" : null, "minValue" : 1, "options" : null, - "controlType" : "INTEGER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "INTEGER" } ], "title" : "POST", "processErrorResponse" : null, @@ -2033,7 +2033,7 @@ }, "properties" : [ { "advancedOption" : null, - "description" : "The URI to make the request to", + "description" : "The URI to make the request to. If HTTP Client Connection defines Base URI, then this value is appended to it.", "displayCondition" : null, "expressionEnabled" : null, "hidden" : null, @@ -2042,7 +2042,7 @@ "name" : "uri", "type" : "STRING", "defaultValue" : "", - "exampleValue" : null, + "exampleValue" : "/", "label" : "URI", "placeholder" : "https://example.com/index.html", "controlType" : "TEXT", @@ -2184,14 +2184,14 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : null, "description" : "Query parameters to send.", @@ -2245,14 +2245,14 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Body Parameters to send.", @@ -2286,8 +2286,8 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" }, { "advancedOption" : null, "description" : null, @@ -2327,8 +2327,8 @@ "label" : null, "placeholder" : null, "options" : null, - "controlType" : "DATE", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "DATE" }, { "advancedOption" : null, "description" : null, @@ -2344,8 +2344,8 @@ "label" : null, "placeholder" : null, "options" : null, - "controlType" : "DATE_TIME", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "DATE_TIME" }, { "advancedOption" : null, "description" : null, @@ -2363,8 +2363,8 @@ "maxValue" : null, "minValue" : null, "options" : null, - "controlType" : "INTEGER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "INTEGER" }, { "advancedOption" : null, "description" : null, @@ -2400,8 +2400,8 @@ "minValue" : null, "numberPrecision" : null, "options" : null, - "controlType" : "NUMBER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "NUMBER" }, { "advancedOption" : null, "description" : null, @@ -2420,8 +2420,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : null, "description" : null, @@ -2457,14 +2457,14 @@ "label" : null, "placeholder" : null, "options" : null, - "controlType" : "TIME", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "TIME" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "XML content to send.", @@ -2483,8 +2483,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Body parameters to send.", @@ -2619,8 +2619,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Body parameters to send.", @@ -2659,8 +2659,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "The raw text to send.", @@ -2858,8 +2858,8 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" }, { "advancedOption" : null, "description" : null, @@ -2899,8 +2899,8 @@ "label" : null, "placeholder" : null, "options" : null, - "controlType" : "DATE", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "DATE" }, { "advancedOption" : null, "description" : null, @@ -2916,8 +2916,8 @@ "label" : null, "placeholder" : null, "options" : null, - "controlType" : "DATE_TIME", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "DATE_TIME" }, { "advancedOption" : null, "description" : null, @@ -2935,8 +2935,8 @@ "maxValue" : null, "minValue" : null, "options" : null, - "controlType" : "INTEGER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "INTEGER" }, { "advancedOption" : null, "description" : null, @@ -2972,8 +2972,8 @@ "minValue" : null, "numberPrecision" : null, "options" : null, - "controlType" : "NUMBER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "NUMBER" }, { "advancedOption" : null, "description" : null, @@ -2992,8 +2992,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : null, "description" : null, @@ -3029,14 +3029,14 @@ "label" : null, "placeholder" : null, "options" : null, - "controlType" : "TIME", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "TIME" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "XML content to send.", @@ -3055,8 +3055,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Body parameters to send.", @@ -3191,8 +3191,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Body parameters to send.", @@ -3231,8 +3231,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "The raw text to send.", @@ -3502,8 +3502,8 @@ "maxValue" : null, "minValue" : 1, "options" : null, - "controlType" : "INTEGER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "INTEGER" } ], "title" : "PUT", "processErrorResponse" : null, @@ -3524,7 +3524,7 @@ }, "properties" : [ { "advancedOption" : null, - "description" : "The URI to make the request to", + "description" : "The URI to make the request to. If HTTP Client Connection defines Base URI, then this value is appended to it.", "displayCondition" : null, "expressionEnabled" : null, "hidden" : null, @@ -3533,7 +3533,7 @@ "name" : "uri", "type" : "STRING", "defaultValue" : "", - "exampleValue" : null, + "exampleValue" : "/", "label" : "URI", "placeholder" : "https://example.com/index.html", "controlType" : "TEXT", @@ -3675,14 +3675,14 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : null, "description" : "Query parameters to send.", @@ -3736,14 +3736,14 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Body Parameters to send.", @@ -3777,8 +3777,8 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" }, { "advancedOption" : null, "description" : null, @@ -3818,8 +3818,8 @@ "label" : null, "placeholder" : null, "options" : null, - "controlType" : "DATE", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "DATE" }, { "advancedOption" : null, "description" : null, @@ -3835,8 +3835,8 @@ "label" : null, "placeholder" : null, "options" : null, - "controlType" : "DATE_TIME", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "DATE_TIME" }, { "advancedOption" : null, "description" : null, @@ -3854,8 +3854,8 @@ "maxValue" : null, "minValue" : null, "options" : null, - "controlType" : "INTEGER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "INTEGER" }, { "advancedOption" : null, "description" : null, @@ -3891,8 +3891,8 @@ "minValue" : null, "numberPrecision" : null, "options" : null, - "controlType" : "NUMBER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "NUMBER" }, { "advancedOption" : null, "description" : null, @@ -3911,8 +3911,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : null, "description" : null, @@ -3948,14 +3948,14 @@ "label" : null, "placeholder" : null, "options" : null, - "controlType" : "TIME", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "TIME" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "XML content to send.", @@ -3974,8 +3974,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Body parameters to send.", @@ -4110,8 +4110,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Body parameters to send.", @@ -4150,8 +4150,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "The raw text to send.", @@ -4349,8 +4349,8 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" }, { "advancedOption" : null, "description" : null, @@ -4390,8 +4390,8 @@ "label" : null, "placeholder" : null, "options" : null, - "controlType" : "DATE", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "DATE" }, { "advancedOption" : null, "description" : null, @@ -4407,8 +4407,8 @@ "label" : null, "placeholder" : null, "options" : null, - "controlType" : "DATE_TIME", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "DATE_TIME" }, { "advancedOption" : null, "description" : null, @@ -4426,8 +4426,8 @@ "maxValue" : null, "minValue" : null, "options" : null, - "controlType" : "INTEGER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "INTEGER" }, { "advancedOption" : null, "description" : null, @@ -4463,8 +4463,8 @@ "minValue" : null, "numberPrecision" : null, "options" : null, - "controlType" : "NUMBER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "NUMBER" }, { "advancedOption" : null, "description" : null, @@ -4483,8 +4483,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : null, "description" : null, @@ -4520,14 +4520,14 @@ "label" : null, "placeholder" : null, "options" : null, - "controlType" : "TIME", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "TIME" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "XML content to send.", @@ -4546,8 +4546,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Body parameters to send.", @@ -4682,8 +4682,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Body parameters to send.", @@ -4722,8 +4722,8 @@ "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "The raw text to send.", @@ -4993,8 +4993,8 @@ "maxValue" : null, "minValue" : 1, "options" : null, - "controlType" : "INTEGER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "INTEGER" } ], "title" : "PATCH", "processErrorResponse" : null, @@ -5015,7 +5015,7 @@ }, "properties" : [ { "advancedOption" : null, - "description" : "The URI to make the request to", + "description" : "The URI to make the request to. If HTTP Client Connection defines Base URI, then this value is appended to it.", "displayCondition" : null, "expressionEnabled" : null, "hidden" : null, @@ -5024,7 +5024,7 @@ "name" : "uri", "type" : "STRING", "defaultValue" : "", - "exampleValue" : null, + "exampleValue" : "/", "label" : "URI", "placeholder" : "https://example.com/index.html", "controlType" : "TEXT", @@ -5166,14 +5166,14 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : null, "description" : "Query parameters to send.", @@ -5227,14 +5227,14 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Returns the full response data instead of only the body.", @@ -5368,8 +5368,8 @@ "maxValue" : null, "minValue" : 1, "options" : null, - "controlType" : "INTEGER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "INTEGER" } ], "title" : "DELETE", "processErrorResponse" : null, @@ -5390,7 +5390,7 @@ }, "properties" : [ { "advancedOption" : null, - "description" : "The URI to make the request to", + "description" : "The URI to make the request to. If HTTP Client Connection defines Base URI, then this value is appended to it.", "displayCondition" : null, "expressionEnabled" : null, "hidden" : null, @@ -5399,7 +5399,7 @@ "name" : "uri", "type" : "STRING", "defaultValue" : "", - "exampleValue" : null, + "exampleValue" : "/", "label" : "URI", "placeholder" : "https://example.com/index.html", "controlType" : "TEXT", @@ -5541,14 +5541,14 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : null, "description" : "Query parameters to send.", @@ -5602,14 +5602,14 @@ "minItems" : null, "multipleValues" : null, "options" : null, - "controlType" : "ARRAY_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "ARRAY_BUILDER" } ], "multipleValues" : null, "options" : null, "properties" : null, - "controlType" : "OBJECT_BUILDER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "OBJECT_BUILDER" }, { "advancedOption" : true, "description" : "Returns the full response data instead of only the body.", @@ -5743,8 +5743,8 @@ "maxValue" : null, "minValue" : 1, "options" : null, - "controlType" : "INTEGER", - "optionsDataSource" : null + "optionsDataSource" : null, + "controlType" : "INTEGER" } ], "title" : "HEAD", "processErrorResponse" : null, diff --git a/server/libs/platform/platform-component/platform-component-service/src/main/java/com/bytechef/platform/component/definition/HttpClientExecutor.java b/server/libs/platform/platform-component/platform-component-service/src/main/java/com/bytechef/platform/component/definition/HttpClientExecutor.java index 223b7224447..924e663c354 100644 --- a/server/libs/platform/platform-component/platform-component-service/src/main/java/com/bytechef/platform/component/definition/HttpClientExecutor.java +++ b/server/libs/platform/platform-component/platform-component-service/src/main/java/com/bytechef/platform/component/definition/HttpClientExecutor.java @@ -23,6 +23,7 @@ import com.bytechef.commons.util.MimeTypeUtils; import com.bytechef.commons.util.OptionalUtils; import com.bytechef.commons.util.XmlUtils; +import com.bytechef.component.definition.Authorization; import com.bytechef.component.definition.Authorization.ApplyResponse; import com.bytechef.component.definition.Context; import com.bytechef.component.definition.Context.Http; @@ -195,7 +196,7 @@ HttpClient createHttpClient( } if (!configuration.isDisableAuthorization() && (componentConnection != null) && - componentConnection.authorizationName() != null) { + Authorization.AuthorizationType.isApplicable(componentConnection.authorizationName())) { applyAuthorization(headers, queryParameters, componentName, componentConnection, context); @@ -401,6 +402,18 @@ private void processParameters(String prefix, Map parameters, FormBodyPubl }); } + /** + * Gets interceptor that scans valid response bodyContent for information on token refresh errors. + * + * @param componentName + * @param componentVersion + * @param componentOperationName + * @param connectionVersion + * @param authorizationName + * @param credentialsBeRefreshed + * @param isAction + * @return + */ private Methanol.Interceptor getInterceptor( String componentName, int componentVersion, String componentOperationName, int connectionVersion, String authorizationName, boolean credentialsBeRefreshed, boolean isAction) { diff --git a/server/libs/platform/platform-component/platform-component-service/src/main/java/com/bytechef/platform/component/helper/TokenRefreshHelper.java b/server/libs/platform/platform-component/platform-component-service/src/main/java/com/bytechef/platform/component/helper/TokenRefreshHelper.java index bc784e3ab2b..0bcaf57200d 100644 --- a/server/libs/platform/platform-component/platform-component-service/src/main/java/com/bytechef/platform/component/helper/TokenRefreshHelper.java +++ b/server/libs/platform/platform-component/platform-component-service/src/main/java/com/bytechef/platform/component/helper/TokenRefreshHelper.java @@ -74,7 +74,9 @@ public V executeSingleConnectionFunction( try { return performFunction.apply(componentConnection, context); } catch (Exception exception) { - if (componentConnection == null || componentConnection.authorizationName() == null) { + if (componentConnection == null || + Authorization.AuthorizationType.isApplicable(componentConnection.authorizationName())) { + throw exception; }