@Test public void testRealDecoder() throws Exception { // Just verifies that "secure" tokens get routed to the right decoder class. try { new DefaultSecurityTokenCodec(new FakeContainerConfig("secure")); fail("Should have thrown"); } catch (RuntimeException e) { assertTrue("root cause should have been FileNotFoundException: " + e, e.getMessage().contains("FileNotFoundException: container key file: somecontainer")); } } }
@Test public void testInvalidDecoder() throws Exception { try { new DefaultSecurityTokenCodec(new FakeContainerConfig("garbage")); fail("Should have thrown"); } catch (RuntimeException e) { assertTrue("exception should contain garbage: " + e, e.getMessage().contains("garbage")); } }
@Test public void testInvalidDecoder() throws Exception { try { new DefaultSecurityTokenCodec(new FakeContainerConfig("garbage")); fail("Should have thrown"); } catch (RuntimeException e) { assertTrue("exception should contain garbage: " + e, e.getMessage().contains("garbage")); } }
@Test public void testBasicDecoder() throws Exception { DefaultSecurityTokenCodec codec = new DefaultSecurityTokenCodec( new FakeContainerConfig("insecure")); Long expires = System.currentTimeMillis() / 1000 + 500; // 50 seconds in the future String token = "o:v:app:domain:appurl:12345:container:" + Long.toString(expires, 10); Map<String, String> parameters = Collections.singletonMap( SecurityTokenCodec.SECURITY_TOKEN_NAME, token); SecurityToken st = codec.createToken(parameters); assertEquals("o", st.getOwnerId()); assertEquals("v", st.getViewerId()); assertEquals("appurl", st.getAppUrl()); assertEquals("container", st.getContainer()); assertEquals(expires, st.getExpiresAt()); }
@Test public void testBasicDecoder() throws Exception { DefaultSecurityTokenCodec codec = new DefaultSecurityTokenCodec( new FakeContainerConfig("insecure")); Long expires = System.currentTimeMillis() / 1000 + 500; // 50 seconds in the future String token = "o:v:app:domain:appurl:12345:container:" + Long.toString(expires, 10); Map<String, String> parameters = Collections.singletonMap( SecurityTokenCodec.SECURITY_TOKEN_NAME, token); SecurityToken st = codec.createToken(parameters); assertEquals("o", st.getOwnerId()); assertEquals("v", st.getViewerId()); assertEquals("appurl", st.getAppUrl()); assertEquals("container", st.getContainer()); assertEquals(expires, st.getExpiresAt()); }
@Test public void testBasicDecoder() throws Exception { DefaultSecurityTokenCodec codec = new DefaultSecurityTokenCodec( new FakeContainerConfig("insecure")); Long expires = System.currentTimeMillis() / 1000 + 500; // 50 seconds in the future String token = "o:v:app:domain:appurl:12345:container:" + Long.toString(expires, 10); Map<String, String> parameters = Collections.singletonMap( SecurityTokenCodec.SECURITY_TOKEN_NAME, token); SecurityToken st = codec.createToken(parameters); assertEquals("o", st.getOwnerId()); assertEquals("v", st.getViewerId()); assertEquals("appurl", st.getAppUrl()); assertEquals("container", st.getContainer()); assertEquals(expires, st.getExpiresAt()); }
@Test public void testBasicDecoder() throws Exception { DefaultSecurityTokenCodec codec = new DefaultSecurityTokenCodec( new FakeContainerConfig("insecure")); String token = "o:v:app:domain:appurl:12345:container"; Map<String, String> parameters = Collections.singletonMap( SecurityTokenCodec.SECURITY_TOKEN_NAME, token); SecurityToken st = codec.createToken(parameters); assertEquals("o", st.getOwnerId()); assertEquals("v", st.getViewerId()); assertEquals("appurl", st.getAppUrl()); assertEquals("container", st.getContainer()); }
@Test public void testBasicDecoder() throws Exception { DefaultSecurityTokenCodec codec = new DefaultSecurityTokenCodec( new FakeContainerConfig("insecure")); String token = "o:v:app:domain:appurl:12345:container"; Map<String, String> parameters = Collections.singletonMap( SecurityTokenCodec.SECURITY_TOKEN_NAME, token); SecurityToken st = codec.createToken(parameters); assertEquals("o", st.getOwnerId()); assertEquals("v", st.getViewerId()); assertEquals("appurl", st.getAppUrl()); assertEquals("container", st.getContainer()); }
@Test public void testRealDecoder() throws Exception { // Just verifies that "secure" tokens get routed to the right decoder class. DefaultSecurityTokenCodec securityTokenCodec = new DefaultSecurityTokenCodec(new FakeContainerConfig("secure")); assertTrue(securityTokenCodec.getCodec() instanceof BlobCrypterSecurityTokenCodec); } }
@Test public void testInvalidDecoder() throws Exception { try { new DefaultSecurityTokenCodec(new FakeContainerConfig("garbage")); fail("Should have thrown"); } catch (RuntimeException e) { assertTrue("exception should contain garbage: " + e, e.getMessage().contains("garbage")); } }
@Test public void testInvalidDecoder() throws Exception { try { new DefaultSecurityTokenCodec(new FakeContainerConfig("garbage")); fail("Should have thrown"); } catch (RuntimeException e) { assertTrue("exception should contain garbage: " + e, e.getMessage().contains("garbage")); } }
@Test public void testNullDecoder() throws Exception { try { new DefaultSecurityTokenCodec(new FakeContainerConfig(null)); fail("Should have thrown"); } catch (RuntimeException e) { assertTrue("exception should contain null: " + e, e.getMessage().contains("null")); } }
@Test public void testRealDecoder() throws Exception { // Just verifies that "secure" tokens get routed to the right decoder class. DefaultSecurityTokenCodec securityTokenCodec = new DefaultSecurityTokenCodec(new FakeContainerConfig("secure")); assertTrue(securityTokenCodec.getCodec() instanceof BlobCrypterSecurityTokenCodec); } }
@Test public void testRealDecoder() throws Exception { // Just verifies that "secure" tokens get routed to the right decoder class. try { new DefaultSecurityTokenCodec(new FakeContainerConfig("secure")); fail("Should have thrown"); } catch (RuntimeException e) { assertTrue("root cause should have been FileNotFoundException: " + e, e.getMessage().contains("FileNotFoundException: container key file: somecontainer")); } } }
@Test public void testNullDecoder() throws Exception { try { new DefaultSecurityTokenCodec(new FakeContainerConfig(null)); fail("Should have thrown"); } catch (RuntimeException e) { assertTrue("exception should contain null: " + e, e.getMessage().contains("null")); } }
@Test public void testRealDecoder() throws Exception { // Just verifies that "secure" tokens get routed to the right decoder class. DefaultSecurityTokenCodec securityTokenCodec = new DefaultSecurityTokenCodec(new FakeContainerConfig("secure")); assertTrue(securityTokenCodec.getCodec() instanceof BlobCrypterSecurityTokenCodec); } }
@Test public void testNullDecoder() throws Exception { try { new DefaultSecurityTokenCodec(new FakeContainerConfig(null)); fail("Should have thrown"); } catch (RuntimeException e) { assertTrue("exception should contain null: " + e, e.getMessage().contains("null")); } }
@Test public void testNullDecoder() throws Exception { try { new DefaultSecurityTokenCodec(new FakeContainerConfig(null)); fail("Should have thrown"); } catch (RuntimeException e) { assertTrue("exception should contain null: " + e, e.getMessage().contains("null")); } }
@Test public void testNullDecoder() throws Exception { try { new DefaultSecurityTokenCodec(new FakeContainerConfig(null)); fail("Should have thrown"); } catch (RuntimeException e) { assertTrue("exception should contain null: " + e, e.getMessage().contains("null")); } }
@Test public void testInvalidDecoder() throws Exception { try { new DefaultSecurityTokenCodec(new FakeContainerConfig("garbage")); fail("Should have thrown"); } catch (RuntimeException e) { assertTrue("exception should contain garbage: " + e, e.getMessage().contains("garbage")); } }