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 f4fd53445 TIKA-4272: apply fixes to ms graph connector
f4fd53445 is described below
commit f4fd5344549fcbcad0543547c84101d90c5ff98f
Author: Nicholas DiPiazza <[email protected]>
AuthorDate: Fri Nov 1 15:48:19 2024 -0500
TIKA-4272: apply fixes to ms graph connector
---
.../microsoftgraph/MicrosoftGraphFetcher.java | 121 +++++++++++++++------
.../config/AadCredentialConfigBase.java | 50 ---------
.../config/ClientCertificateCredentialsConfig.java | 40 -------
.../config/ClientSecretCredentialsConfig.java | 30 -----
.../config/MicrosoftGraphFetcherConfig.java | 50 ++++++++-
.../microsoftgraph/MicrosoftGraphFetcherTest.java | 104 ------------------
.../config/AadCredentialConfigBaseTest.java | 66 -----------
.../src/test/resources/tika-pipes-test-config.xml | 8 +-
8 files changed, 136 insertions(+), 333 deletions(-)
diff --git
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/MicrosoftGraphFetcher.java
b/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/MicrosoftGraphFetcher.java
index 3c27795d3..6733fb3a7 100644
---
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/MicrosoftGraphFetcher.java
+++
b/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/MicrosoftGraphFetcher.java
@@ -17,13 +17,18 @@
package org.apache.tika.pipes.fetchers.microsoftgraph;
import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Files;
+import java.util.Base64;
+import java.util.List;
import java.util.Map;
import com.azure.identity.ClientCertificateCredentialBuilder;
import com.azure.identity.ClientSecretCredentialBuilder;
import com.microsoft.graph.serviceclient.GraphServiceClient;
+import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,11 +38,10 @@ import org.apache.tika.config.InitializableProblemHandler;
import org.apache.tika.config.Param;
import org.apache.tika.exception.TikaConfigException;
import org.apache.tika.exception.TikaException;
+import org.apache.tika.io.TikaInputStream;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.parser.ParseContext;
import org.apache.tika.pipes.fetcher.AbstractFetcher;
-import
org.apache.tika.pipes.fetchers.microsoftgraph.config.ClientCertificateCredentialsConfig;
-import
org.apache.tika.pipes.fetchers.microsoftgraph.config.ClientSecretCredentialsConfig;
import
org.apache.tika.pipes.fetchers.microsoftgraph.config.MicrosoftGraphFetcherConfig;
/**
@@ -47,15 +51,17 @@ import
org.apache.tika.pipes.fetchers.microsoftgraph.config.MicrosoftGraphFetche
public class MicrosoftGraphFetcher extends AbstractFetcher implements
Initializable {
private static final Logger LOGGER =
LoggerFactory.getLogger(MicrosoftGraphFetcher.class);
private GraphServiceClient graphClient;
- private MicrosoftGraphFetcherConfig microsoftGraphFetcherConfig;
+ private MicrosoftGraphFetcherConfig config = new
MicrosoftGraphFetcherConfig();
private long[] throttleSeconds;
+ private boolean spoolToTemp;
+
public MicrosoftGraphFetcher() {
}
- public MicrosoftGraphFetcher(MicrosoftGraphFetcherConfig
microsoftGraphFetcherConfig) {
- this.microsoftGraphFetcherConfig = microsoftGraphFetcherConfig;
+ public MicrosoftGraphFetcher(MicrosoftGraphFetcherConfig config) {
+ this.config = config;
}
/**
@@ -82,32 +88,64 @@ public class MicrosoftGraphFetcher extends AbstractFetcher
implements Initializa
this.throttleSeconds = throttleSeconds;
}
+ @Field
+ public void setSpoolToTemp(boolean spoolToTemp) {
+ this.spoolToTemp = spoolToTemp;
+ }
+
+ @Field
+ public void setTenantId(String tenantId) {
+ config.setTenantId(tenantId);
+ }
+
+ @Field
+ public void setClientId(String clientId) {
+ config.setClientId(clientId);
+ }
+
+ @Field
+ public void setClientSecret(String clientSecret) {
+ config.setClientSecret(clientSecret);
+ }
+
+ @Field
+ public void setCertificateBytesBase64(String certificateBytesBase64) {
+ config.setCertificateBytesBase64(certificateBytesBase64);
+ }
+
+ @Field
+ public void setCertificatePassword(String certificatePassword) {
+ config.setCertificatePassword(certificatePassword);
+ }
+
+ @Field
+ public void setScopes(List<String> scopes) {
+ this.config.setScopes(scopes);
+ }
+
@Override
public void initialize(Map<String, Param> map) {
- String[] scopes = microsoftGraphFetcherConfig
- .getScopes().toArray(new String[0]);
- if (microsoftGraphFetcherConfig.getCredentials() instanceof
ClientCertificateCredentialsConfig) {
- ClientCertificateCredentialsConfig credentials =
- (ClientCertificateCredentialsConfig)
microsoftGraphFetcherConfig.getCredentials();
- graphClient = new GraphServiceClient(
- new
ClientCertificateCredentialBuilder().clientId(credentials.getClientId())
-
.tenantId(credentials.getTenantId()).pfxCertificate(
- new
ByteArrayInputStream(credentials.getCertificateBytes()))
-
.clientCertificatePassword(credentials.getCertificatePassword())
- .build(), scopes);
- } else if (microsoftGraphFetcherConfig.getCredentials() instanceof
ClientSecretCredentialsConfig) {
- ClientSecretCredentialsConfig credentials =
- (ClientSecretCredentialsConfig)
microsoftGraphFetcherConfig.getCredentials();
- graphClient = new GraphServiceClient(
- new
ClientSecretCredentialBuilder().tenantId(credentials.getTenantId())
- .clientId(credentials.getClientId())
-
.clientSecret(credentials.getClientSecret()).build(), scopes);
+ String[] scopes = config
+ .getScopes()
+ .toArray(new String[0]);
+ if (config.getCertificateBytesBase64() != null) {
+ graphClient = new GraphServiceClient(new
ClientCertificateCredentialBuilder()
+ .clientId(config.getClientId())
+ .tenantId(config.getTenantId())
+ .pfxCertificate(new
ByteArrayInputStream(Base64.getDecoder().decode(config.getCertificateBytesBase64())))
+ .clientCertificatePassword(config.getCertificatePassword())
+ .build(), scopes);
+ } else if (config.getClientSecret() != null) {
+ graphClient = new GraphServiceClient(new
ClientSecretCredentialBuilder()
+ .tenantId(config.getTenantId())
+ .clientId(config.getClientId())
+ .clientSecret(config.getClientSecret())
+ .build(), scopes);
}
}
@Override
- public void checkInitialization(InitializableProblemHandler
initializableProblemHandler)
- throws TikaConfigException {
+ public void checkInitialization(InitializableProblemHandler
initializableProblemHandler) throws TikaConfigException {
}
@Override
@@ -115,26 +153,45 @@ public class MicrosoftGraphFetcher extends
AbstractFetcher implements Initializa
int tries = 0;
Exception ex;
do {
+ long start = System.currentTimeMillis();
try {
- long start = System.currentTimeMillis();
String[] fetchKeySplit = fetchKey.split(",");
String siteDriveId = fetchKeySplit[0];
String driveItemId = fetchKeySplit[1];
- InputStream is =
graphClient.drives().byDriveId(siteDriveId).items()
- .byDriveItemId(driveItemId).content().get();
+ InputStream is = graphClient
+ .drives()
+ .byDriveId(siteDriveId)
+ .items()
+ .byDriveItemId(driveItemId)
+ .content()
+ .get();
- long elapsed = System.currentTimeMillis() - start;
- LOGGER.debug("Total to fetch {}", elapsed);
- return is;
+ if (is == null) {
+ throw new IOException("Empty input stream when we tried to
parse " + fetchKey);
+ }
+ if (spoolToTemp) {
+ File tempFile = Files
+ .createTempFile("spooled-temp", ".dat")
+ .toFile();
+ FileUtils.copyInputStreamToFile(is, tempFile);
+ LOGGER.info("Spooled to temp file {}", tempFile);
+ return TikaInputStream.get(tempFile.toPath());
+ }
+ return TikaInputStream.get(is);
} catch (Exception e) {
LOGGER.warn("Exception fetching on retry=" + tries, e);
ex = e;
+ } finally {
+ long elapsed = System.currentTimeMillis() - start;
+ LOGGER.debug("Total to fetch {}", elapsed);
}
LOGGER.warn("Sleeping for {} seconds before retry",
throttleSeconds[tries]);
try {
Thread.sleep(throttleSeconds[tries]);
} catch (InterruptedException e) {
- Thread.currentThread().interrupt();
+ Thread
+ .currentThread()
+ .interrupt();
}
} while (++tries < throttleSeconds.length);
throw new TikaException("Could not parse " + fetchKey, ex);
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
deleted file mode 100644
index 9d9b3a695..000000000
---
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/AadCredentialConfigBase.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;
-
-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;
-
- public String getTenantId() {
- return tenantId;
- }
-
- public AadCredentialConfigBase setTenantId(String tenantId) {
- this.tenantId = tenantId;
- return this;
- }
-
- public String getClientId() {
- return clientId;
- }
-
- public AadCredentialConfigBase setClientId(String clientId) {
- this.clientId = clientId;
- return this;
- }
-}
diff --git
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/ClientCertificateCredentialsConfig.java
b/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/ClientCertificateCredentialsConfig.java
deleted file mode 100644
index 2927519f1..000000000
---
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/ClientCertificateCredentialsConfig.java
+++ /dev/null
@@ -1,40 +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 ClientCertificateCredentialsConfig extends
AadCredentialConfigBase {
- private byte[] certificateBytes;
- private String certificatePassword;
-
- public byte[] getCertificateBytes() {
- return certificateBytes;
- }
-
- public ClientCertificateCredentialsConfig setCertificateBytes(byte[]
certificateBytes) {
- this.certificateBytes = certificateBytes;
- return this;
- }
-
- public String getCertificatePassword() {
- return certificatePassword;
- }
-
- public ClientCertificateCredentialsConfig setCertificatePassword(String
certificatePassword) {
- this.certificatePassword = certificatePassword;
- return this;
- }
-}
diff --git
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/ClientSecretCredentialsConfig.java
b/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/ClientSecretCredentialsConfig.java
deleted file mode 100644
index 2989af941..000000000
---
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/ClientSecretCredentialsConfig.java
+++ /dev/null
@@ -1,30 +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 ClientSecretCredentialsConfig extends AadCredentialConfigBase {
- private String clientSecret;
-
- public String getClientSecret() {
- return clientSecret;
- }
-
- public ClientSecretCredentialsConfig setClientSecret(String clientSecret) {
- this.clientSecret = clientSecret;
- return this;
- }
-}
diff --git
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/MicrosoftGraphFetcherConfig.java
b/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/MicrosoftGraphFetcherConfig.java
index 04a43e000..f9bc5b1b8 100644
---
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/MicrosoftGraphFetcherConfig.java
+++
b/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/main/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/MicrosoftGraphFetcherConfig.java
@@ -24,8 +24,11 @@ import org.apache.tika.pipes.fetcher.config.AbstractConfig;
public class MicrosoftGraphFetcherConfig extends AbstractConfig {
private long[] throttleSeconds;
private boolean spoolToTemp;
- private AadCredentialConfigBase credentials;
-
+ protected String tenantId;
+ protected String clientId;
+ private String clientSecret;
+ private String certificateBytesBase64;
+ private String certificatePassword;
private List<String> scopes = new ArrayList<>();
public boolean isSpoolToTemp() {
@@ -46,12 +49,47 @@ public class MicrosoftGraphFetcherConfig extends
AbstractConfig {
return this;
}
- public AadCredentialConfigBase getCredentials() {
- return credentials;
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ public MicrosoftGraphFetcherConfig setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ return this;
+ }
+
+ public String getClientId() {
+ return clientId;
+ }
+
+ public MicrosoftGraphFetcherConfig setClientId(String clientId) {
+ this.clientId = clientId;
+ return this;
+ }
+
+ public String getClientSecret() {
+ return clientSecret;
+ }
+
+ public MicrosoftGraphFetcherConfig setClientSecret(String clientSecret) {
+ this.clientSecret = clientSecret;
+ return this;
+ }
+
+ public String getCertificateBytesBase64() {
+ return certificateBytesBase64;
+ }
+
+ public void setCertificateBytesBase64(String certificateBytesBase64) {
+ this.certificateBytesBase64 = certificateBytesBase64;
+ }
+
+ public String getCertificatePassword() {
+ return certificatePassword;
}
- public MicrosoftGraphFetcherConfig setCredentials(AadCredentialConfigBase
credentials) {
- this.credentials = credentials;
+ public MicrosoftGraphFetcherConfig setCertificatePassword(String
certificatePassword) {
+ this.certificatePassword = certificatePassword;
return this;
}
diff --git
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/test/java/org/apache/tika/pipes/fetchers/microsoftgraph/MicrosoftGraphFetcherTest.java
b/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/test/java/org/apache/tika/pipes/fetchers/microsoftgraph/MicrosoftGraphFetcherTest.java
deleted file mode 100644
index 7dda9fb7a..000000000
---
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/test/java/org/apache/tika/pipes/fetchers/microsoftgraph/MicrosoftGraphFetcherTest.java
+++ /dev/null
@@ -1,104 +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;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.util.Collections;
-
-import com.microsoft.graph.drives.DrivesRequestBuilder;
-import com.microsoft.graph.drives.item.DriveItemRequestBuilder;
-import com.microsoft.graph.drives.item.items.ItemsRequestBuilder;
-import com.microsoft.graph.drives.item.items.item.DriveItemItemRequestBuilder;
-import
com.microsoft.graph.drives.item.items.item.content.ContentRequestBuilder;
-import com.microsoft.graph.serviceclient.GraphServiceClient;
-import org.apache.commons.io.IOUtils;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.tika.metadata.Metadata;
-import org.apache.tika.parser.ParseContext;
-import
org.apache.tika.pipes.fetchers.microsoftgraph.config.ClientCertificateCredentialsConfig;
-import
org.apache.tika.pipes.fetchers.microsoftgraph.config.MicrosoftGraphFetcherConfig;
-
-@ExtendWith(MockitoExtension.class)
-class MicrosoftGraphFetcherTest {
- private static final Logger LOGGER =
LoggerFactory.getLogger(MicrosoftGraphFetcherTest.class);
- static byte[] certificateBytes = "test cert file
here".getBytes(StandardCharsets.UTF_8);
- static String certificatePassword = "somepasswordhere";
- static String clientId = "12312312-1234-1234-1234-112312312313";
- static String tenantId = "32132132-4332-5432-4321-121231231232";
- static String siteDriveId = "99999999-1234-1111-1111-12312312312";
- static String driveItemid = "asfsadfsadfsafdusahdfiuhfdsusadfjuafiagfaigf";
-
- @Mock
- GraphServiceClient graphClient;
- @Spy
- @SuppressWarnings("unused")
- MicrosoftGraphFetcherConfig msGraphFetcherConfig = new
MicrosoftGraphFetcherConfig().setCredentials(
- new
ClientCertificateCredentialsConfig().setCertificateBytes(certificateBytes)
-
.setCertificatePassword(certificatePassword).setClientId(clientId)
-
.setTenantId(tenantId)).setScopes(Collections.singletonList(".default"));
-
- @Mock
- DrivesRequestBuilder drivesRequestBuilder;
-
- @Mock
- DriveItemRequestBuilder driveItemRequestBuilder;
-
- @Mock
- ItemsRequestBuilder itemsRequestBuilder;
-
- @Mock
- DriveItemItemRequestBuilder driveItemItemRequestBuilder;
-
- @Mock
- ContentRequestBuilder contentRequestBuilder;
-
- @InjectMocks
- MicrosoftGraphFetcher microsoftGraphFetcher;
-
- @Test
- void fetch() throws Exception {
- try (AutoCloseable ignored = MockitoAnnotations.openMocks(this)) {
-
Mockito.when(graphClient.drives()).thenReturn(drivesRequestBuilder);
- Mockito.when(drivesRequestBuilder.byDriveId(siteDriveId))
- .thenReturn(driveItemRequestBuilder);
-
Mockito.when(driveItemRequestBuilder.items()).thenReturn(itemsRequestBuilder);
- Mockito.when(itemsRequestBuilder.byDriveItemId(driveItemid))
- .thenReturn(driveItemItemRequestBuilder);
-
Mockito.when(driveItemItemRequestBuilder.content()).thenReturn(contentRequestBuilder);
- String content = "content";
- Mockito.when(contentRequestBuilder.get())
- .thenReturn(new
ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)));
- InputStream resultingInputStream =
- microsoftGraphFetcher.fetch(siteDriveId + "," +
driveItemid, new Metadata(), new ParseContext());
- Assertions.assertEquals(content,
- IOUtils.toString(resultingInputStream,
StandardCharsets.UTF_8));
- }
- }
-}
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
deleted file mode 100644
index 1935d4950..000000000
---
a/tika-pipes/tika-fetchers/tika-fetcher-microsoft-graph/src/test/java/org/apache/tika/pipes/fetchers/microsoftgraph/config/AadCredentialConfigBaseTest.java
+++ /dev/null
@@ -1,66 +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.
- *
- *
- */
-
-/*
- *
- * * 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("xx");
- creds.setClientId("clientid");
- creds.setTenantId("tenantid");
-
- String str = new
ObjectMapper().writeValueAsString(microsoftGraphFetcherConfig);
- MicrosoftGraphFetcherConfig backAgain = new
ObjectMapper().readValue(str, MicrosoftGraphFetcherConfig.class);
-
Assertions.assertEquals(microsoftGraphFetcherConfig.getCredentials().getClientId(),
backAgain.getCredentials().getClientId());
- ClientCertificateCredentialsConfig backAgainCreds =
(ClientCertificateCredentialsConfig) backAgain.getCredentials();
-
Assertions.assertEquals(microsoftGraphFetcherConfig.getCredentials().getClientId(),
backAgain.getCredentials().getClientId());
- Assertions.assertEquals("nick", new
String(backAgainCreds.getCertificateBytes()));
- }
-}
diff --git a/tika-pipes/tika-grpc/src/test/resources/tika-pipes-test-config.xml
b/tika-pipes/tika-grpc/src/test/resources/tika-pipes-test-config.xml
index e4006edb3..374be17c3 100644
--- a/tika-pipes/tika-grpc/src/test/resources/tika-pipes-test-config.xml
+++ b/tika-pipes/tika-grpc/src/test/resources/tika-pipes-test-config.xml
@@ -13,8 +13,7 @@
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.
--->
-<properties>
+--><properties>
<async>
<staleFetcherTimeoutSeconds>600</staleFetcherTimeoutSeconds>
<staleFetcherDelaySeconds>60</staleFetcherDelaySeconds>
@@ -30,6 +29,5 @@
<maxForEmitBatchBytes>-1</maxForEmitBatchBytes> <!-- disable emit -->
</params>
</pipes>
- <fetchers>
- </fetchers>
-</properties>
+ <fetchers><fetcher
class="org.apache.tika.pipes.fetchers.microsoftgraph.MicrosoftGraphFetcher"><name>testgraph</name><spoolToTemp>true</spoolToTemp><tenantId>4f55380c-fc4a-4ee1-9922-f64ceafa086b</tenantId><clientId>a6a88ddb-5938-470c-a11a-7aa310913052</clientId><certificateBytesBase64>MIIPmQIBAzCCD18GCSqGSIb3DQEHAaCCD1AEgg9MMIIPSDCCBX8GCSqGSIb3DQEHBqCCBXAwggVsAgEAMIIFZQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQMwDgQIvnVRfbIJhPoCAggAgIIFOHBfKM/jWUcTHo3tRQIp5X8TMIeLHlNNjXTRBYT/X8eyNH/cGvk16tikekPL
[...]
+</properties>
\ No newline at end of file