use of com.google.cloud.conformance.storage.v1.Method in project java-storage by googleapis.
the class V4PostPolicyTest method testCases.
/**
* Loads all of the tests and return a {@code Collection<Object[]>} representing the set of tests.
* Each entry in the returned collection is the set of parameters to the constructor of this test
* class.
*
* <p>The results of this method will then be run by JUnit's Parameterized test runner
*/
@Parameters(name = "{2}")
public static Collection<Object[]> testCases() throws IOException {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream credentialsStream = cl.getResourceAsStream(SERVICE_ACCOUNT_JSON_RESOURCE);
assertNotNull(String.format("Unable to load service account json: %s", SERVICE_ACCOUNT_JSON_RESOURCE), credentialsStream);
InputStream dataJson = cl.getResourceAsStream(TEST_DATA_JSON_RESOURCE);
assertNotNull(String.format("Unable to load test definition: %s", TEST_DATA_JSON_RESOURCE), dataJson);
ServiceAccountCredentials serviceAccountCredentials = ServiceAccountCredentials.fromStream(credentialsStream);
InputStreamReader reader = new InputStreamReader(dataJson, Charsets.UTF_8);
TestFile.Builder testBuilder = TestFile.newBuilder();
JsonFormat.parser().merge(reader, testBuilder);
TestFile testFile = testBuilder.build();
List<PostPolicyV4Test> tests = testFile.getPostPolicyV4TestsList();
ArrayList<Object[]> data = new ArrayList<>(tests.size());
for (PostPolicyV4Test test : tests) {
data.add(new Object[] { test, serviceAccountCredentials, test.getDescription() });
}
return data;
}
use of com.google.cloud.conformance.storage.v1.Method in project jargyle by jh3nd3rs0n.
the class Socks5HostResolver method resolve.
@Override
public InetAddress resolve(final String host) throws IOException {
if (host == null) {
return InetAddress.getLoopbackAddress();
}
Properties properties = this.socks5Client.getProperties();
AddressType addressType = AddressType.valueForString(host);
if (!addressType.equals(AddressType.DOMAINNAME) || !properties.getValue(Socks5PropertySpecConstants.SOCKS5_RESOLVE_USE_RESOLVE_COMMAND).booleanValue()) {
return InetAddress.getByName(host);
}
Socket socket = this.socks5Client.newInternalSocket();
this.socks5Client.configureInternalSocket(socket);
Socket sock = this.socks5Client.getConnectedInternalSocket(socket, true);
Method method = this.socks5Client.negotiateMethod(sock);
MethodEncapsulation methodEncapsulation = this.socks5Client.doMethodSubnegotiation(method, sock);
Socket sck = methodEncapsulation.getSocket();
Socks5Request socks5Req = Socks5Request.newInstance(Command.RESOLVE, host, 0);
this.socks5Client.sendSocks5Request(socks5Req, sck);
Socks5Reply socks5Rep = null;
try {
socks5Rep = this.socks5Client.receiveSocks5Reply(sck);
} catch (FailureSocks5ReplyException e) {
Reply reply = e.getFailureSocks5Reply().getReply();
if (reply.equals(Reply.HOST_UNREACHABLE)) {
throw new UnknownHostException(host);
} else {
throw e;
}
}
InetAddress inetAddress = InetAddress.getByName(socks5Rep.getServerBoundAddress());
return InetAddress.getByAddress(host, inetAddress.getAddress());
}
Aggregations