HttpUrlConnectionFactory.mockedConnection = mockedConnection2;
Util.prepareMockedUrlConnection(mockedConnection);
final String addHostResponse = "{\"tenant_discovery_endpoint\":\"valid endpoint\"}";
Mockito.when(mockedConnection.getInputStream()).thenReturn(Util.createInputStream(addHostResponse));
Mockito.when(mockedConnection.getResponseCode()).thenReturn(200);
<BUG>final URL endpointTest = new URL("https://login.test-direct-add.net/common");
discovery.isValidAuthority(endpointTest);</BUG>
HttpUrlConnectionFactory.mockedConnection = null;
<BUG>assertTrue(discovery.isValidAuthority(endpointTest));
}
}

</BUG>

HttpUrlConnectionFactory.mockedConnection = mockedConnection2;
Util.prepareMockedUrlConnection(mockedConnection);
final String addHostResponse = "{\"tenant_discovery_endpoint\":\"valid endpoint\"}";
Mockito.when(mockedConnection.getInputStream()).thenReturn(Util.createInputStream(addHostResponse));
Mockito.when(mockedConnection.getResponseCode()).thenReturn(200);
final URL endpointTest = new URL("https://login.test-direct-add.net/common");
try {
discovery.isValidAuthority(endpointTest);
HttpUrlConnectionFactory.mockedConnection = null;
assertTrue(discovery.isValidAuthority(endpointTest));
} catch (final AuthenticationException e) {
fail();
