Package com.nimbusds.oauth2.sdk

Source Code of com.nimbusds.oauth2.sdk.SAML2BearerGrantTest

package com.nimbusds.oauth2.sdk;


import java.util.Map;

import junit.framework.TestCase;

import com.nimbusds.jose.util.Base64URL;


/**
* Tests the SAML 2.0 bearer grant.
*/
public class SAML2BearerGrantTest extends TestCase {


  public void testConstructorAndParser()
    throws Exception {

    Base64URL assertion = new Base64URL("abc"); // dummy XML assertion

    SAML2BearerGrant grant = new SAML2BearerGrant(assertion);
    assertEquals(GrantType.SAML2_BEARER, grant.getType());
    assertEquals(assertion, grant.getSAML2Assertion());
    assertEquals("abc", grant.getAssertion());

    Map<String,String> params = grant.toParameters();
    assertEquals(GrantType.SAML2_BEARER.getValue(), params.get("grant_type"));
    assertEquals("abc", params.get("assertion"));
    assertEquals(2, params.size());

    grant = SAML2BearerGrant.parse(params);
    assertEquals(GrantType.SAML2_BEARER, grant.getType());
    assertEquals("abc", grant.getSAML2Assertion().toString());
    assertEquals("abc", grant.getAssertion());
  }
}
TOP

Related Classes of com.nimbusds.oauth2.sdk.SAML2BearerGrantTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.