Commit c2829de2 authored by Alinga Yeung's avatar Alinga Yeung
Browse files

Story 1657 rework. Added a test case for unsupported principal.

parent e6ec0673
Loading
Loading
Loading
Loading
+21 −0
Original line number Original line Diff line number Diff line
@@ -73,7 +73,9 @@ import java.net.MalformedURLException;
import java.net.URI;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URL;
import java.security.Principal;


import javax.management.remote.JMXPrincipal;
import javax.security.auth.Subject;
import javax.security.auth.Subject;


import org.apache.log4j.Level;
import org.apache.log4j.Level;
@@ -163,6 +165,25 @@ public class UserClientTest
        }
        }
    }
    }
    
    
    @Test
    public void testSubjectWithUnsupportedPrincipal() throws URISyntaxException, MalformedURLException
    {
    	Principal principal = new JMXPrincipal("APIName");
        try
        {
            // test subject augmentation given a subject with more than one principal
            Subject subject = new Subject();
            subject.getPrincipals().add(principal);
            this.createUserClient().augmentSubject(subject);
            Assert.fail("Expecting an IllegalArgumentException.");
        }
        catch(IllegalArgumentException e)
        {
            String expected = "Subject has unsupported principal " + principal.getName();
            Assert.assertEquals(expected, e.getMessage());
        }
    }
   
    protected UserClient createUserClient() throws URISyntaxException, MalformedURLException
    protected UserClient createUserClient() throws URISyntaxException, MalformedURLException
    {
    {
    	RegistryClient regClient = new RegistryClient();
    	RegistryClient regClient = new RegistryClient();