Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Minor HTTP protocol updates

Rich Turnera10fc208e29b
diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/OAuthGrant.java b/agent/src/main/java/org/openremote/agent/protocol/http/OAuthGrant.java
index 1a9fc8a1b..de2bb87fa 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/http/OAuthGrant.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/http/OAuthGrant.java
@@ -23,6 +23,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import org.openremote.container.Container;
+import org.openremote.model.value.ObjectValue;
+import org.openremote.model.value.Values;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
@@ -85,4 +88,14 @@ public abstract class OAuthGrant {
public String getScope() {
return valueMap.getFirst(VALUE_KEY_SCOPE);
}
+
+ public ObjectValue toObjectValue() {
+ try {
+ return Values.<ObjectValue>parse(Container.JSON.writeValueAsString(this)).orElse(null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
}
diff --git a/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy
index ab2942af7..bf65212cf 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy
@@ -311,14 +311,13 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
),
new MetaItem(
HttpClientProtocol.META_PROTOCOL_OAUTH_GRANT,
- Values.<ObjectValue>parse(Container.JSON.writeValueAsString(
- new OAuthPasswordGrant("https://mockapi/token",
- "TestClient",
- "TestSecret",
- "scope1 scope2",
- "testuser",
- "password")
- )).get()),
+ new OAuthPasswordGrant("https://mockapi/token",
+ "TestClient",
+ "TestSecret",
+ "scope1 scope2",
+ "testuser",
+ "password").toObjectValue()
+ ),
new MetaItem(
HttpClientProtocol.META_PROTOCOL_FOLLOW_REDIRECTS,
Values.create(true)
@@ -383,14 +382,13 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
),
new MetaItem(
HttpClientProtocol.META_PROTOCOL_OAUTH_GRANT,
- Values.<ObjectValue>parse(Container.JSON.writeValueAsString(
- new OAuthPasswordGrant("https://mockapi/token",
- "TestClient",
- "TestSecret",
- "scope1 scope2",
- "testuser",
- "password")
- )).get()),
+ new OAuthPasswordGrant("https://mockapi/token",
+ "TestClient",
+ "TestSecret",
+ "scope1 scope2",
+ "testuser",
+ "password").toObjectValue()
+ ),
new MetaItem(
HttpClientProtocol.META_PROTOCOL_FOLLOW_REDIRECTS,
Values.create(true)
@@ -556,14 +554,13 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
),
new MetaItem(
HttpClientProtocol.META_PROTOCOL_OAUTH_GRANT,
- Values.<ObjectValue>parse(Container.JSON.writeValueAsString(
- new OAuthPasswordGrant("https://mockapi/token",
- "TestClient",
- "TestSecret",
- "scope1 scope2",
- "testuser",
- "password")
- )).get()),
+ new OAuthPasswordGrant("https://mockapi/token",
+ "TestClient",
+ "TestSecret",
+ "scope1 scope2",
+ "testuser",
+ "password").toObjectValue()
+ ),
new MetaItem(
HttpClientProtocol.META_FAILURE_CODES,
Values.createArray()
@@ -579,14 +576,13 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
),
new MetaItem(
HttpClientProtocol.META_PROTOCOL_OAUTH_GRANT,
- Values.<ObjectValue>parse(Container.JSON.writeValueAsString(
- new OAuthPasswordGrant("https://mockapi/token",
- "TestClient",
- "TestSecret",
- "scope1 scope2",
- "testuser",
- "password")
- )).get()),
+ new OAuthPasswordGrant("https://mockapi/token",
+ "TestClient",
+ "TestSecret",
+ "scope1 scope2",
+ "testuser",
+ "password").toObjectValue()
+ ),
new MetaItem(
HttpClientProtocol.META_FAILURE_CODES,
Values.createArray()
@@ -602,14 +598,13 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
),
new MetaItem(
HttpClientProtocol.META_PROTOCOL_OAUTH_GRANT,
- Values.<ObjectValue>parse(Container.JSON.writeValueAsString(
- new OAuthPasswordGrant("https://mockapi/token",
- "TestClient",
- "TestSecret",
- "scope1 scope2",
- "testuser",
- "password")
- )).get()),
+ new OAuthPasswordGrant("https://mockapi/token",
+ "TestClient",
+ "TestSecret",
+ "scope1 scope2",
+ "testuser",
+ "password").toObjectValue()
+ ),
new MetaItem(
HttpClientProtocol.META_PROTOCOL_FOLLOW_REDIRECTS,
Values.create(true)