// Path: endpoints-control/src/main/java/com/google/api/control/model/MethodRegistry.java
// public static final class AuthInfo {
//   private final Map<String, Set<String>> providerIdsToAudiences;
// 
//   public AuthInfo(Map<String, Set<String>> providerIdsToAudiences) {
//     Preconditions.checkNotNull(providerIdsToAudiences);
//     this.providerIdsToAudiences = providerIdsToAudiences;
//   }
// 
//   public boolean isProviderIdAllowed(String providerid) {
//     Preconditions.checkNotNull(providerid);
//     return this.providerIdsToAudiences.containsKey(providerid);
//   }
// 
//   public Set<String> getAudiencesForProvider(String providerId) {
//     Preconditions.checkNotNull(providerId);
// 
//     if (this.providerIdsToAudiences.containsKey(providerId)) {
//       return this.providerIdsToAudiences.get(providerId);
//     }
//     return ImmutableSet.<String>of();
//   }
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.api.AuthProvider;
import com.google.api.AuthProvider.Builder;
import com.google.api.Authentication;
import com.google.api.client.util.Clock;
import com.google.api.control.model.MethodRegistry.AuthInfo;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.net.HttpHeaders;
import com.google.common.util.concurrent.UncheckedExecutionException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.jose4j.jwk.JsonWebKeySet;
import org.jose4j.jwk.RsaJsonWebKey;
import org.jose4j.jwt.NumericDate;
import org.jose4j.lang.JoseException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
/*
 * Copyright 2016 Google Inc. All Rights Reserved.
 *
 * 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 com.google.api.auth;







public final class IntegrationTest {

  private static final String JWKS_PATH = "jwks";
  private static final String X509_PATH = "x509";

  private static final int TEST_SERVER_PORT = 8765;
  private static final String ISSUER = "https://localhost" + ":" + TEST_SERVER_PORT;
  private static final String PROVIDER_ID = "provider-id";
  private static final String TEST_SERVER_URL = ISSUER;

  private static final String KEY_ID = "key-id";
  private static final RsaJsonWebKey RSA_JSON_WEB_KEY = TestUtils.generateRsaJsonWebKey(KEY_ID);

  private static final Set<String> AUDIENCES = ImmutableSet.of("aud1", "aud2");
  private static final String EMAIL = "user@localhost.com";
  private static final String SERVICE_NAME = "service-name";
  private static final String SUBJECT = "subject-id";
  private static final Map<String, Set<String>> PROVIDER_ID_AUDIENCES =
      ImmutableMap.of(PROVIDER_ID, AUDIENCES);

  private static final IntegrationTestServer server =
      new IntegrationTestServer(TEST_SERVER_PORT, Resource.class);

  private final HttpServletRequest httpRequest = mock(HttpServletRequest.class);
// Path: endpoints-control/src/main/java/com/google/api/control/model/MethodRegistry.java
// public static final class AuthInfo {
//   private final Map<String, Set<String>> providerIdsToAudiences;
// 
//   public AuthInfo(Map<String, Set<String>> providerIdsToAudiences) {
//     Preconditions.checkNotNull(providerIdsToAudiences);
//     this.providerIdsToAudiences = providerIdsToAudiences;
//   }
// 
//   public boolean isProviderIdAllowed(String providerid) {
//     Preconditions.checkNotNull(providerid);
//     return this.providerIdsToAudiences.containsKey(providerid);
//   }
// 
//   public Set<String> getAudiencesForProvider(String providerId) {
//     Preconditions.checkNotNull(providerId);
// 
//     if (this.providerIdsToAudiences.containsKey(providerId)) {
//       return this.providerIdsToAudiences.get(providerId);
//     }
//     return ImmutableSet.<String>of();
//   }
// }


// Path: endpoints-auth/src/integration-test/java/com/google/api/auth/IntegrationTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.api.AuthProvider;
import com.google.api.AuthProvider.Builder;
import com.google.api.Authentication;
import com.google.api.client.util.Clock;
import com.google.api.control.model.MethodRegistry.AuthInfo;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.net.HttpHeaders;
import com.google.common.util.concurrent.UncheckedExecutionException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.jose4j.jwk.JsonWebKeySet;
import org.jose4j.jwk.RsaJsonWebKey;
import org.jose4j.jwt.NumericDate;
import org.jose4j.lang.JoseException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/*
 * Copyright 2016 Google Inc. All Rights Reserved.
 *
 * 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 com.google.api.auth;







public final class IntegrationTest {

  private static final String JWKS_PATH = "jwks";
  private static final String X509_PATH = "x509";

  private static final int TEST_SERVER_PORT = 8765;
  private static final String ISSUER = "https://localhost" + ":" + TEST_SERVER_PORT;
  private static final String PROVIDER_ID = "provider-id";
  private static final String TEST_SERVER_URL = ISSUER;

  private static final String KEY_ID = "key-id";
  private static final RsaJsonWebKey RSA_JSON_WEB_KEY = TestUtils.generateRsaJsonWebKey(KEY_ID);

  private static final Set<String> AUDIENCES = ImmutableSet.of("aud1", "aud2");
  private static final String EMAIL = "user@localhost.com";
  private static final String SERVICE_NAME = "service-name";
  private static final String SUBJECT = "subject-id";
  private static final Map<String, Set<String>> PROVIDER_ID_AUDIENCES =
      ImmutableMap.of(PROVIDER_ID, AUDIENCES);

  private static final IntegrationTestServer server =
      new IntegrationTestServer(TEST_SERVER_PORT, Resource.class);

  private final HttpServletRequest httpRequest = mock(HttpServletRequest.class);
  private final AuthInfo authInfo = new AuthInfo(PROVIDER_ID_AUDIENCES);