// Path: src/test/java/org/simplify4u/plugins/utils/ProxyUtil.java
// public static Proxy makeMavenProxy(String proxyUser, String proxyPassword, String id, boolean active) {
//     Proxy proxy = new Proxy();
//     proxy.setHost("localhost");
//     proxy.setActive(active);
//     proxy.setNonProxyHosts("*");
//     proxy.setUsername(proxyUser);
//     proxy.setPassword(proxyPassword);
//     proxy.setId(id);
//     proxy.setProtocol("http");
//     return proxy;
// }
// 
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyId.java
// public interface KeyId {
// 
//     String getHashPath();
// 
//     PGPPublicKey getKeyFromRing(PGPPublicKeyRing publicKeyRing);
// 
//     PGPPublicKeyRing getKeyRingFromRingCollection(PGPPublicKeyRingCollection pgpRingCollection) throws PGPException;
// 
//     /**
//      * Representation of a keyId with long as key.
//      */
//     @EqualsAndHashCode
//     class KeyIdLong implements KeyId {
// 
//         private final Long keyId;
// 
//         KeyIdLong(Long keyId) {
//             this.keyId = keyId;
//         }
// 
//         @Override
//         public String getHashPath() {
//             return String.format("%02X/%02X/%016X.asc", (byte) (keyId >> 56), (byte) (keyId >> 48 & 0xff), keyId);
//         }
// 
//         @Override
//         public PGPPublicKey getKeyFromRing(PGPPublicKeyRing publicKeyRing) {
//             return publicKeyRing.getPublicKey(keyId);
//         }
// 
//         @Override
//         public PGPPublicKeyRing getKeyRingFromRingCollection(PGPPublicKeyRingCollection pgpRingCollection)
//                 throws PGPException {
//             return pgpRingCollection.getPublicKeyRing(keyId);
//         }
// 
//         @Override
//         @JsonValue
//         public String toString() {
//             return String.format("0x%016X", keyId);
//         }
//     }
// 
//     /**
//      * Representation of a keyId with fingerprint as key.
//      */
//     @EqualsAndHashCode
//     class KeyIdFingerprint implements KeyId {
// 
//         private final byte[] fingerprint;
// 
//         KeyIdFingerprint(byte[] fingerprint) {
//             this.fingerprint = fingerprint;
//         }
// 
//         @Override
//         public String getHashPath() {
//             StringBuilder ret = new StringBuilder();
//             ret.append(String.format("%02X/", fingerprint[0]));
//             ret.append(String.format("%02X/", fingerprint[1]));
//             for (byte b: fingerprint) {
//                 ret.append(String.format("%02X", b));
//             }
//             ret.append(".asc");
//             return ret.toString();
//         }
// 
//         @Override
//         public PGPPublicKey getKeyFromRing(PGPPublicKeyRing publicKeyRing) {
//             return publicKeyRing.getPublicKey(fingerprint);
//         }
// 
//         @Override
//         public PGPPublicKeyRing getKeyRingFromRingCollection(PGPPublicKeyRingCollection pgpRingCollection)
//                 throws PGPException {
//             return pgpRingCollection.getPublicKeyRing(fingerprint);
//         }
// 
//         @Override
//         @JsonValue
//         public String toString() {
//             return fingerprintToString(fingerprint);
//         }
// 
//     }
// 
//     static KeyId from(byte[] fingerprint) {
//         return new KeyIdFingerprint(fingerprint);
//     }
// 
//     static KeyId from(Long keyId) {
//         return new KeyIdLong(keyId);
//     }
// }


import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.concurrent.atomic.AtomicInteger;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static org.simplify4u.plugins.utils.ProxyUtil.makeMavenProxy;
import org.apache.http.HttpStatus;
import org.apache.http.StatusLine;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.ProxyAuthenticationStrategy;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Settings;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.testng.MockitoTestNGListener;
import org.simplify4u.plugins.pgp.KeyId;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
/*
 * Copyright 2021 Slawomir Jaranowski
 *
 * 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
 *
 *     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.simplify4u.plugins.keyserver;




@Listeners(MockitoTestNGListener.class)
public class PGPKeysServerClientTest {

    @Mock
    Settings settings;

    @Mock
    MavenSession mavenSession;

    @Mock
    HttpClientBuilder clientBuilder;

    @DataProvider(name = "proxy")
    public static Object[][] emptyProxy() {
        return new Object[][]{
// Path: src/test/java/org/simplify4u/plugins/utils/ProxyUtil.java
// public static Proxy makeMavenProxy(String proxyUser, String proxyPassword, String id, boolean active) {
//     Proxy proxy = new Proxy();
//     proxy.setHost("localhost");
//     proxy.setActive(active);
//     proxy.setNonProxyHosts("*");
//     proxy.setUsername(proxyUser);
//     proxy.setPassword(proxyPassword);
//     proxy.setId(id);
//     proxy.setProtocol("http");
//     return proxy;
// }
// 
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyId.java
// public interface KeyId {
// 
//     String getHashPath();
// 
//     PGPPublicKey getKeyFromRing(PGPPublicKeyRing publicKeyRing);
// 
//     PGPPublicKeyRing getKeyRingFromRingCollection(PGPPublicKeyRingCollection pgpRingCollection) throws PGPException;
// 
//     /**
//      * Representation of a keyId with long as key.
//      */
//     @EqualsAndHashCode
//     class KeyIdLong implements KeyId {
// 
//         private final Long keyId;
// 
//         KeyIdLong(Long keyId) {
//             this.keyId = keyId;
//         }
// 
//         @Override
//         public String getHashPath() {
//             return String.format("%02X/%02X/%016X.asc", (byte) (keyId >> 56), (byte) (keyId >> 48 & 0xff), keyId);
//         }
// 
//         @Override
//         public PGPPublicKey getKeyFromRing(PGPPublicKeyRing publicKeyRing) {
//             return publicKeyRing.getPublicKey(keyId);
//         }
// 
//         @Override
//         public PGPPublicKeyRing getKeyRingFromRingCollection(PGPPublicKeyRingCollection pgpRingCollection)
//                 throws PGPException {
//             return pgpRingCollection.getPublicKeyRing(keyId);
//         }
// 
//         @Override
//         @JsonValue
//         public String toString() {
//             return String.format("0x%016X", keyId);
//         }
//     }
// 
//     /**
//      * Representation of a keyId with fingerprint as key.
//      */
//     @EqualsAndHashCode
//     class KeyIdFingerprint implements KeyId {
// 
//         private final byte[] fingerprint;
// 
//         KeyIdFingerprint(byte[] fingerprint) {
//             this.fingerprint = fingerprint;
//         }
// 
//         @Override
//         public String getHashPath() {
//             StringBuilder ret = new StringBuilder();
//             ret.append(String.format("%02X/", fingerprint[0]));
//             ret.append(String.format("%02X/", fingerprint[1]));
//             for (byte b: fingerprint) {
//                 ret.append(String.format("%02X", b));
//             }
//             ret.append(".asc");
//             return ret.toString();
//         }
// 
//         @Override
//         public PGPPublicKey getKeyFromRing(PGPPublicKeyRing publicKeyRing) {
//             return publicKeyRing.getPublicKey(fingerprint);
//         }
// 
//         @Override
//         public PGPPublicKeyRing getKeyRingFromRingCollection(PGPPublicKeyRingCollection pgpRingCollection)
//                 throws PGPException {
//             return pgpRingCollection.getPublicKeyRing(fingerprint);
//         }
// 
//         @Override
//         @JsonValue
//         public String toString() {
//             return fingerprintToString(fingerprint);
//         }
// 
//     }
// 
//     static KeyId from(byte[] fingerprint) {
//         return new KeyIdFingerprint(fingerprint);
//     }
// 
//     static KeyId from(Long keyId) {
//         return new KeyIdLong(keyId);
//     }
// }


// Path: src/test/java/org/simplify4u/plugins/keyserver/PGPKeysServerClientTest.java
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.concurrent.atomic.AtomicInteger;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static org.simplify4u.plugins.utils.ProxyUtil.makeMavenProxy;
import org.apache.http.HttpStatus;
import org.apache.http.StatusLine;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.ProxyAuthenticationStrategy;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Settings;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.testng.MockitoTestNGListener;
import org.simplify4u.plugins.pgp.KeyId;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;

/*
 * Copyright 2021 Slawomir Jaranowski
 *
 * 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
 *
 *     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.simplify4u.plugins.keyserver;




@Listeners(MockitoTestNGListener.class)
public class PGPKeysServerClientTest {

    @Mock
    Settings settings;

    @Mock
    MavenSession mavenSession;

    @Mock
    HttpClientBuilder clientBuilder;

    @DataProvider(name = "proxy")
    public static Object[][] emptyProxy() {
        return new Object[][]{
                {makeMavenProxy("", "")},