Search in sources :

Example 1 with UserAuthorizationRequest

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

the class CxDxMessageFactoryImpl method createUserAuthorizationRequest.

/* (non-Javadoc)
   * @see net.java.slee.resource.diameter.cxdx.CxDxMessageFactory#createUserAuthorizationRequest(java.lang.String)
   */
public UserAuthorizationRequest createUserAuthorizationRequest(String sessionId) throws IllegalArgumentException {
    UserAuthorizationRequest uar = createUserAuthorizationRequest();
    uar.setSessionId(sessionId);
    return uar;
}
Also used : UserAuthorizationRequest(net.java.slee.resource.diameter.cxdx.events.UserAuthorizationRequest)

Example 2 with UserAuthorizationRequest

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

the class CxDxFactoriesTest method testClientSessionApplicationIdChangeUAR.

@Test
public void testClientSessionApplicationIdChangeUAR() 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 originalUAR = clientSession.createUserAuthorizationRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalUAR);
    // now we switch..
    originalUAR = null;
    isVendor = !isVendor;
    ((CxDxMessageFactoryImpl) cxdxMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    UserAuthorizationRequest changedUAR = clientSession.createUserAuthorizationRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedUAR);
    // 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) 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 3 with UserAuthorizationRequest

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

the class CxDxFactoriesTest method hasTFlagSetUAA.

@Test
public void hasTFlagSetUAA() throws Exception {
    UserAuthorizationRequest uar = cxdxMessageFactory.createUserAuthorizationRequest();
    ((DiameterMessageImpl) uar).getGenericData().setReTransmitted(true);
    assertTrue("The 'T' flag should be set in User-Authorization-Request", uar.getHeader().isPotentiallyRetransmitted());
    serverSession.fetchSessionData(uar);
    UserAuthorizationAnswer uaa = serverSession.createUserAuthorizationAnswer();
    assertFalse("The 'T' flag should not be set in User-Authorization-Answer", uaa.getHeader().isPotentiallyRetransmitted());
}
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 4 with UserAuthorizationRequest

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

the class CxDxFactoriesTest method testMessageFactoryApplicationIdChangeUAR.

@Test
public void testMessageFactoryApplicationIdChangeUAR() 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 originalUAR = cxdxMessageFactory.createUserAuthorizationRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalUAR);
    // now we switch..
    originalUAR = null;
    isVendor = !isVendor;
    ((CxDxMessageFactoryImpl) cxdxMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    UserAuthorizationRequest changedUAR = cxdxMessageFactory.createUserAuthorizationRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedUAR);
    // 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) 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 5 with UserAuthorizationRequest

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

the class CxDxFactoriesTest method testGettersAndSettersUAR.

@Test
public void testGettersAndSettersUAR() throws Exception {
    UserAuthorizationRequest uar = cxdxMessageFactory.createUserAuthorizationRequest();
    int nFailures = CxDxAvpAssistant.INSTANCE.testMethods(uar, UserAuthorizationRequest.class);
    assertEquals("Some methods have failed. See logs for more details.", 0, nFailures);
}
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