1   package com.atlassian.seraph.util;
2   
3   import junit.framework.TestCase;
4   
5   public class TestSecurityUtils extends TestCase
6   {
7       public void testEncodeBasicAuthorizationCredentials() throws Exception
8       {
9           String basicAuthEncoded = SecurityUtils.encodeBasicAuthorizationCredentials("foo", "bar");
10          // "foo:bar" encoded => "Zm9vOmJhcg=="
11          assertEquals("Basic Zm9vOmJhcg==", basicAuthEncoded);
12      }
13      
14      public void testDecodeBasicAuthorizationCredentials() throws Exception
15      {
16          // "foo:bar" encoded => "Zm9vOmJhcg=="
17          SecurityUtils.UserPassCredentials credentials = SecurityUtils.decodeBasicAuthorizationCredentials("Basic Zm9vOmJhcg==");
18          assertEquals("foo", credentials.getUsername());
19          assertEquals("bar", credentials.getPassword());
20      }
21  }