@Test public void testSendPermittedStructureMatchWithAddress() throws Exception { JsonObject match = new JsonObject().put("fib", "wib").put("oop", 12); sockJSHandler.bridge(defaultOptions.addInboundPermitted(new PermittedOptions().setMatch(match).setAddress(addr))); testSend(addr, match); JsonObject json1 = match.copy(); json1.put("blah", "foob"); testSend(addr, json1); json1.remove("fib"); testError(new JsonObject().put("type", "send").put("address", addr).put("body", json1), "access_denied"); testError(new JsonObject().put("type", "send").put("address", "otheraddress").put("body", json1), "access_denied"); }
@Test public void testSendPermittedStructureMatch() throws Exception { JsonObject match = new JsonObject().put("fib", "wib").put("oop", 12); sockJSHandler.bridge(defaultOptions.addInboundPermitted(new PermittedOptions().setMatch(match))); testSend(addr, match); JsonObject json1 = match.copy(); json1.put("blah", "foob"); testSend(addr, json1); json1.remove("fib"); testError(new JsonObject().put("type", "send").put("address", addr).put("body", json1), "access_denied"); }
@Test public void testRegisterPermittedStructureMatch() throws Exception { JsonObject match = new JsonObject().put("fib", "wib").put("oop", 12); sockJSHandler.bridge(defaultOptions.addOutboundPermitted(new PermittedOptions().setMatch(match))); testReceive(addr, match); JsonObject json1 = match.copy(); json1.put("blah", "foob"); testReceive(addr, json1); JsonObject json2 = json1.copy(); json2.remove("fib"); testReceiveFail(addr, json2); }
@Test public void testRegisterPermittedStructureMatchWithAddress() throws Exception { JsonObject match = new JsonObject().put("fib", "wib").put("oop", 12); sockJSHandler.bridge(defaultOptions.addOutboundPermitted(new PermittedOptions().setMatch(match).setAddress(addr))); testReceive(addr, match); JsonObject json1 = match.copy(); json1.put("blah", "foob"); testReceive(addr, json1); JsonObject json2 = json1.copy(); json2.remove("fib"); testReceiveFail(addr, json2); }
assertSame(options, options.setAddressRegex(addressRegex)); assertSame(options, options.setRequiredAuthority(requiredAuthority)); assertSame(options, options.setMatch(match)); assertEquals(address, options.getAddress()); assertEquals(addressRegex, options.getAddressRegex()); assertSame(copy, copy.setAddressRegex(TestUtils.randomAlphaString(10))); assertSame(copy, copy.setRequiredAuthority(TestUtils.randomAlphaString(10))); assertSame(copy, copy.setMatch(new JsonObject().put(TestUtils.randomAlphaString(10), TestUtils.randomAlphaString(10)))); assertSame(options, options.setAddress(address)); assertSame(options, options.setAddressRegex(addressRegex)); assertSame(options, options.setRequiredAuthority(requiredAuthority)); assertSame(options, options.setMatch(match));
@Test public void testSendPermittedStructureMatch() throws Exception { JsonObject match = new JsonObject().put("fib", "wib").put("oop", 12); sockJSHandler.bridge(defaultOptions.addInboundPermitted(new PermittedOptions().setMatch(match))); testSend(addr, match); JsonObject json1 = match.copy(); json1.put("blah", "foob"); testSend(addr, json1); json1.remove("fib"); testError(new JsonObject().put("type", "send").put("address", addr).put("body", json1), "access_denied"); }
@Test public void testSendPermittedStructureMatchWithAddress() throws Exception { JsonObject match = new JsonObject().put("fib", "wib").put("oop", 12); sockJSHandler.bridge(defaultOptions.addInboundPermitted(new PermittedOptions().setMatch(match).setAddress(addr))); testSend(addr, match); JsonObject json1 = match.copy(); json1.put("blah", "foob"); testSend(addr, json1); json1.remove("fib"); testError(new JsonObject().put("type", "send").put("address", addr).put("body", json1), "access_denied"); testError(new JsonObject().put("type", "send").put("address", "otheraddress").put("body", json1), "access_denied"); }
@Test public void testRegisterPermittedStructureMatch() throws Exception { JsonObject match = new JsonObject().put("fib", "wib").put("oop", 12); sockJSHandler.bridge(defaultOptions.addOutboundPermitted(new PermittedOptions().setMatch(match))); testReceive(addr, match); JsonObject json1 = match.copy(); json1.put("blah", "foob"); testReceive(addr, json1); JsonObject json2 = json1.copy(); json2.remove("fib"); testReceiveFail(addr, json2); }
@Test public void testRegisterPermittedStructureMatchWithAddress() throws Exception { JsonObject match = new JsonObject().put("fib", "wib").put("oop", 12); sockJSHandler.bridge(defaultOptions.addOutboundPermitted(new PermittedOptions().setMatch(match).setAddress(addr))); testReceive(addr, match); JsonObject json1 = match.copy(); json1.put("blah", "foob"); testReceive(addr, json1); JsonObject json2 = json1.copy(); json2.remove("fib"); testReceiveFail(addr, json2); }
assertSame(options, options.setAddressRegex(addressRegex)); assertSame(options, options.setRequiredAuthority(requiredAuthority)); assertSame(options, options.setMatch(match)); assertEquals(address, options.getAddress()); assertEquals(addressRegex, options.getAddressRegex()); assertSame(copy, copy.setAddressRegex(TestUtils.randomAlphaString(10))); assertSame(copy, copy.setRequiredAuthority(TestUtils.randomAlphaString(10))); assertSame(copy, copy.setMatch(new JsonObject().put(TestUtils.randomAlphaString(10), TestUtils.randomAlphaString(10)))); assertSame(options, options.setAddress(address)); assertSame(options, options.setAddressRegex(addressRegex)); assertSame(options, options.setRequiredAuthority(requiredAuthority)); assertSame(options, options.setMatch(match));