This is an automated email from the ASF dual-hosted git repository.

ndipiazza pushed a commit to branch tika-grpc-3x-features
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/tika-grpc-3x-features by this 
push:
     new 6fcbd4748 TIKA-4272: fix an issue where the aad credential was not 
serializing properly
6fcbd4748 is described below

commit 6fcbd474823b847e4a8ad528fcec2329daab507c
Author: Nicholas DiPiazza <[email protected]>
AuthorDate: Fri Nov 1 13:41:50 2024 -0500

    TIKA-4272: fix an issue where the aad credential was not serializing 
properly
---
 .../tika-fetcher-microsoft-graph/pom.xml           |  2 +-
 .../config/AadCredentialConfigBase.java            | 10 +++++
 .../Client2CertificateCredentialsConfig.java       | 50 ----------------------
 .../config/AadCredentialConfigBaseTest.java        | 43 +++++++++++++++++++
 4 files changed, 54 insertions(+), 51 deletions(-)

diff --git a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/pom.xml 
b/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/pom.xml
index 6169c2858..6d4f31e45 100644
--- a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/pom.xml
+++ b/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/pom.xml
@@ -36,7 +36,7 @@
     <azure-identity.version>1.11.0</azure-identity.version>
     <microsoft-graph.version>6.4.0</microsoft-graph.version>
     
<microsoft-kiota-serialization-json.version>1.1.1</microsoft-kiota-serialization-json.version>
-    <junit-jupiter-engine.version>5.9.2</junit-jupiter-engine.version>
+    <junit-jupiter-engine.version>5.11.0-M2</junit-jupiter-engine.version>
     <wiremock.version>3.3.1</wiremock.version>
     <mockito-junit-jupiter.version>5.3.1</mockito-junit-jupiter.version>
     <nimbus-jose-jwt.version>9.37.3</nimbus-jose-jwt.version>
diff --git 
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/AadCredentialConfigBase.java
 
b/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/AadCredentialConfigBase.java
index e4204739c..9d9b3a695 100644
--- 
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/AadCredentialConfigBase.java
+++ 
b/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/AadCredentialConfigBase.java
@@ -16,6 +16,16 @@
  */
 package org.apache.tika.pipes.fetchers.microsoftgraph.config;
 
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonSubTypes;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
+@JsonSubTypes({
+        @JsonSubTypes.Type(value = ClientCertificateCredentialsConfig.class, 
name = "ClientCertificateCredentials"),
+        @JsonSubTypes.Type(value = ClientSecretCredentialsConfig.class, name = 
"ClientSecretCredentials") }
+)
 public abstract class AadCredentialConfigBase {
     private String tenantId;
     private String clientId;
diff --git 
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/Client2CertificateCredentialsConfig.java
 
b/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/Client2CertificateCredentialsConfig.java
deleted file mode 100644
index d9128373e..000000000
--- 
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/Client2CertificateCredentialsConfig.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
- *
- *     http://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 org.apache.tika.pipes.fetchers.microsoftgraph.config;
-
-public class Client2CertificateCredentialsConfig {
-    private String tenantId;
-    private String clientId;
-    private String clientSecret;
-
-    public String getTenantId() {
-        return tenantId;
-    }
-
-    public Client2CertificateCredentialsConfig setTenantId(String tenantId) {
-        this.tenantId = tenantId;
-        return this;
-    }
-
-    public String getClientId() {
-        return clientId;
-    }
-
-    public Client2CertificateCredentialsConfig setClientId(String clientId) {
-        this.clientId = clientId;
-        return this;
-    }
-
-    public String getClientSecret() {
-        return clientSecret;
-    }
-
-    public Client2CertificateCredentialsConfig setClientSecret(String 
clientSecret) {
-        this.clientSecret = clientSecret;
-        return this;
-    }
-}
diff --git 
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/test/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/AadCredentialConfigBaseTest.java
 
b/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/test/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/AadCredentialConfigBaseTest.java
new file mode 100644
index 000000000..c17947aea
--- /dev/null
+++ 
b/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/test/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/AadCredentialConfigBaseTest.java
@@ -0,0 +1,43 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  * contributor license agreements.  See the NOTICE file distributed with
+ *  * this work for additional information regarding copyright ownership.
+ *  * The ASF licenses this file to You 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
+ *  *
+ *  *     http://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 org.apache.tika.pipes.fetchers.microsoftgraph.config;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+class AadCredentialConfigBaseTest {
+    @Test
+    void checkFormat() throws JsonProcessingException {
+        MicrosoftGraphFetcherConfig microsoftGraphFetcherConfig = new 
MicrosoftGraphFetcherConfig();
+        var creds = new ClientCertificateCredentialsConfig();
+        microsoftGraphFetcherConfig.setCredentials(creds);
+        creds.setCertificateBytes("nick".getBytes());
+        creds.setCertificatePassword("gkowefqHrryTFP");
+        creds.setClientId("a6a88ddb-5938-470c-a11a-7aa310913052");
+        creds.setTenantId("4f55380c-fc4a-4ee1-9922-f64ceafa086b");
+
+        String str = new 
ObjectMapper().writeValueAsString(microsoftGraphFetcherConfig);
+        MicrosoftGraphFetcherConfig backAgain = new 
ObjectMapper().readValue(str, MicrosoftGraphFetcherConfig.class);
+        
Assertions.assertEquals(microsoftGraphFetcherConfig.getCredentials().getClientId(),
 backAgain.getCredentials().getClientId());
+    }
+}

Reply via email to