Search in sources :

Example 6 with UserAuthorizationRequest

use of net.java.slee.resource.diameter.cxdx.events.UserAuthorizationRequest in project jain-slee.diameter by RestComm.

the class CxDxFactoriesTest method testServerSessionApplicationIdChangeUAA.

@Test
public void testServerSessionApplicationIdChangeUAA() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((CxDxMessageFactoryImpl) cxdxMessageFactory).getApplicationId();
    boolean isAuth = originalAppId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
    boolean isAcct = originalAppId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
    boolean isVendor = originalAppId.getVendorId() != 0L;
    assertTrue("Invalid Application-Id (" + originalAppId + "). Should only, and at least, contain either Auth or Acct value.", (isAuth && !isAcct) || (!isAuth && isAcct));
    System.out.println("Default VENDOR-ID for CxDx is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    UserAuthorizationRequest uar = cxdxMessageFactory.createUserAuthorizationRequest();
    serverSession.fetchSessionData(uar);
    UserAuthorizationAnswer originalUAA = serverSession.createUserAuthorizationAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalUAA);
    // now we switch..
    originalUAA = null;
    isVendor = !isVendor;
    ((CxDxMessageFactoryImpl) cxdxMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    UserAuthorizationAnswer changedUAA = serverSession.createUserAuthorizationAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedUAA);
    // revert back to default
    ((CxDxMessageFactoryImpl) cxdxMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : UserAuthorizationRequest(net.java.slee.resource.diameter.cxdx.events.UserAuthorizationRequest) UserAuthorizationAnswer(net.java.slee.resource.diameter.cxdx.events.UserAuthorizationAnswer) CxDxMessageFactoryImpl(org.mobicents.slee.resource.diameter.cxdx.CxDxMessageFactoryImpl) ApplicationId(org.jdiameter.api.ApplicationId) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 7 with UserAuthorizationRequest

use of net.java.slee.resource.diameter.cxdx.events.UserAuthorizationRequest in project jain-slee.diameter by RestComm.

the class CxDxFactoriesTest method isProxiableUAR.

@Test
public void isProxiableUAR() throws Exception {
    UserAuthorizationRequest uar = cxdxMessageFactory.createUserAuthorizationRequest();
    assertTrue("The 'P' bit is not set by default in User-Authorization-Request, it should.", uar.getHeader().isProxiable());
}
Also used : UserAuthorizationRequest(net.java.slee.resource.diameter.cxdx.events.UserAuthorizationRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 8 with UserAuthorizationRequest

use of net.java.slee.resource.diameter.cxdx.events.UserAuthorizationRequest in project jain-slee.diameter by RestComm.

the class CxDxServerSessionImpl method createUserAuthorizationAnswer.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diameter.cxdx.CxDxServerSession#createUserAuthorizationAnswer()
   */
public UserAuthorizationAnswer createUserAuthorizationAnswer() {
    // Make sure we have the correct type of Request
    if (!(lastRequest instanceof UserAuthorizationRequest)) {
        logger.warn("Invalid type of answer for this activity. Type: " + lastRequest);
        return null;
    }
    try {
        // Create the answer
        UserAuthorizationAnswer uaa = (UserAuthorizationAnswer) this.cxdxMessageFactory.createCxDxMessage(lastRequest.getHeader(), new DiameterAvp[] {}, UserAuthorizationAnswer.COMMAND_CODE, cxdxMessageFactory.getApplicationId());
        // Fill session related AVPs, if present
        fillSessionAVPs(uaa);
        return uaa;
    } catch (InternalException e) {
        logger.error("Failed to create User-Authorization-Answer.", e);
    }
    return null;
}
Also used : UserAuthorizationRequest(net.java.slee.resource.diameter.cxdx.events.UserAuthorizationRequest) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) UserAuthorizationAnswer(net.java.slee.resource.diameter.cxdx.events.UserAuthorizationAnswer) InternalException(org.jdiameter.api.InternalException)

Example 9 with UserAuthorizationRequest

use of net.java.slee.resource.diameter.cxdx.events.UserAuthorizationRequest in project jain-slee.diameter by RestComm.

the class CxDxFactoriesTest method isProxiableCopiedUAA.

@Test
public void isProxiableCopiedUAA() throws Exception {
    UserAuthorizationRequest uar = cxdxMessageFactory.createUserAuthorizationRequest();
    serverSession.fetchSessionData(uar);
    UserAuthorizationAnswer uaa = serverSession.createUserAuthorizationAnswer();
    assertEquals("The 'P' bit is not copied from request in User-Authorization-Answer, it should. [RFC3588/6.2]", uar.getHeader().isProxiable(), uaa.getHeader().isProxiable());
    // Reverse 'P' bit ...
    ((DiameterMessageImpl) uar).getGenericData().setProxiable(!uar.getHeader().isProxiable());
    assertTrue("The 'P' bit was not modified in User-Authorization-Request, it should.", uar.getHeader().isProxiable() != uaa.getHeader().isProxiable());
    serverSession.fetchSessionData(uar);
    uaa = serverSession.createUserAuthorizationAnswer();
    assertEquals("The 'P' bit is not copied from request in User-Authorization-Answer, it should. [RFC3588/6.2]", uar.getHeader().isProxiable(), uaa.getHeader().isProxiable());
}
Also used : UserAuthorizationRequest(net.java.slee.resource.diameter.cxdx.events.UserAuthorizationRequest) UserAuthorizationAnswer(net.java.slee.resource.diameter.cxdx.events.UserAuthorizationAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 10 with UserAuthorizationRequest

use of net.java.slee.resource.diameter.cxdx.events.UserAuthorizationRequest in project jain-slee.diameter by RestComm.

the class CxDxFactoriesTest method isRequestUAR.

@Test
public void isRequestUAR() throws Exception {
    UserAuthorizationRequest uar = cxdxMessageFactory.createUserAuthorizationRequest();
    assertTrue("Request Flag in User-Authorization-Request is not set.", uar.getHeader().isRequest());
}
Also used : UserAuthorizationRequest(net.java.slee.resource.diameter.cxdx.events.UserAuthorizationRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

UserAuthorizationRequest (net.java.slee.resource.diameter.cxdx.events.UserAuthorizationRequest)11 Test (org.junit.Test)8 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)8 UserAuthorizationAnswer (net.java.slee.resource.diameter.cxdx.events.UserAuthorizationAnswer)4 ApplicationId (org.jdiameter.api.ApplicationId)3 CxDxMessageFactoryImpl (org.mobicents.slee.resource.diameter.cxdx.CxDxMessageFactoryImpl)3 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)1 InternalException (org.jdiameter.api.InternalException)1