InstanceProviderManager { ProviderScheme getProviderEndpointScheme(URI uri) { String host = uri.getHost(); if (host == null) { LOGGER.error("verifyProviderEndpoint: Provider endpoint {} has no host component", uri.toString()); return ProviderScheme.UNKNOWN; } host = host.toLowerCase(); String scheme = uri.getScheme(); if (scheme == null) { LOGGER.error("verifyProviderEndpoint: Provider endpoint {} has no scheme component", uri.toString()); return ProviderScheme.UNKNOWN; } ProviderScheme schemeType = getProviderScheme(uri); if (schemeType == ProviderScheme.UNKNOWN) { LOGGER.error("verifyProviderEndpoint: Unknown scheme in URI {}", uri.toString()); return ProviderScheme.UNKNOWN; } if (schemeType != ProviderScheme.HTTPS) { return schemeType; } if (!verifyProviderEndpoint(host)) { LOGGER.error("verifyProviderEndpoint: Provider host {} does not match with any of the configured domains", host); return ProviderScheme.UNKNOWN; } return schemeType; } InstanceProviderManager(DataStore dataStore, SSLContext sslContext, KeyStore keyStore);   }
@Test public void testGetProviderEndpointScheme() throws URISyntaxException { InstanceProviderManager provider = new InstanceProviderManager(null, null, null); URI uri = new URI("https: assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.HTTPS); uri = new URI("https: assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.HTTPS); uri = new URI("https: assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.HTTPS); uri = new URI("class: assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.CLASS); uri = new URI("http: assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.UNKNOWN); uri = new URI("https: assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.UNKNOWN); uri = new URI("http: assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.UNKNOWN); uri = new URI("http: assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.UNKNOWN); uri = new URI("http: assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.UNKNOWN); uri = new URI("http: assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.UNKNOWN); uri = new URI("http: assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.UNKNOWN); uri = new URI("http: assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.UNKNOWN); uri = new URI("test.athenz.com/"); assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.UNKNOWN); uri = new URI("file: assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.UNKNOWN); uri = new URI(" assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.UNKNOWN); uri = new URI("test: assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.UNKNOWN); uri = new URI("uri: assertEquals(provider.getProviderEndpointScheme(uri), ProviderScheme.UNKNOWN); }