@Test public void httpProxyRecursion2() throws Exception { List<Main> nodes = new ArrayList<>(); for (int i = 0; i < 4; i++) nodes.add(createMain("node" + (i + 1), false)); nodes.forEach(n->n.config.setIsFreeRegistrationsAllowedFromYaml(true)); PrivateKey myKey = TestKeys.privateKey(3); Client clientProxy = new Client("./src/test_node_config_v2/test_node_config_v2.json",System.getProperty("java.io.tmpdir"),myKey); HashId testHashId = HashId.createRandom(); nodes.get(0).node.getLedger().findOrCreate(testHashId).setState(ItemState.APPROVED).save(); nodes.get(1).node.getLedger().findOrCreate(testHashId).setState(ItemState.DECLINED).save(); nodes.get(2).node.getLedger().findOrCreate(testHashId).setState(ItemState.REVOKED).save(); nodes.get(3).node.getLedger().findOrCreate(testHashId).setState(ItemState.DISCARDED).save(); System.out.println("\n\n-------------------"); Client targetClient1 = clientProxy.getClient(1); Client targetClient2 = clientProxy.getClient(2); BasicHttpClientSession targetSession1 = targetClient1.getSession(); BasicHttpClientSession targetSession2 = targetClient2.getSession(); Binder cmd2 = Binder.of("command", "getState", "params", Binder.of("itemId", testHashId)); Binder command2Params = Binder.of("session_id", targetSession2.getSessionId(), "params", targetSession2.getSessionKey().etaEncrypt(Boss.pack(cmd2))); Binder answer = clientProxy.command("proxy", "url", targetClient2.getUrl(), "command", "command", "params", command2Params); Binder answerBinder = Boss.load(answer.getBinaryOrThrow("result")); String answerError = answerBinder.getBinderOrThrow("response").getStringOrThrow("response"); System.out.println("try recursion v2... answerError: " + answerError); assertEquals("Access denied. Command 'command' is not allowed with 'proxy', use 'proxyCommand' instead.", answerError); System.out.println("-------------------\n\n"); nodes.forEach(n->n.shutdown()); }
public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } Main(String[] args); }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } Main(String[] args); static void main(String[] args); void waitReady(); void shutdown(); void setVerboseLevel(int level); void setUDPVerboseLevel(int level); void restartUDPAdapter(); PublicKey getNodePublicKey(); }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } Main(String[] args); static void main(String[] args); void waitReady(); void shutdown(); void setVerboseLevel(int level); void setUDPVerboseLevel(int level); void restartUDPAdapter(); PublicKey getNodePublicKey(); static final String NODE_VERSION; final Reporter reporter; final BufferedLogger logger; public NetConfig netConfig; public NetworkV2 network; final Config config; public NodeInfo myInfo; public Node node; public ItemCache cache; public ParcelCache parcelCache; public PaidOperationCache paidOperationCache; }