use of net.java.slee.resource.diameter.cxdx.events.UserAuthorizationAnswer 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());
}
use of net.java.slee.resource.diameter.cxdx.events.UserAuthorizationAnswer in project jain-slee.diameter by RestComm.
the class CxDxFactoriesTest method testGettersAndSettersUAA.
@Test
public void testGettersAndSettersUAA() throws Exception {
serverSession.fetchSessionData(cxdxMessageFactory.createUserAuthorizationRequest());
UserAuthorizationAnswer uaa = serverSession.createUserAuthorizationAnswer();
int nFailures = CxDxAvpAssistant.INSTANCE.testMethods(uaa, UserAuthorizationAnswer.class);
assertEquals("Some methods have failed. See logs for more details.", 0, nFailures);
}
use of net.java.slee.resource.diameter.cxdx.events.UserAuthorizationAnswer in project jain-slee.diameter by RestComm.
the class CxDxFactoriesTest method hasDestinationRealmUAA.
@Test
public void hasDestinationRealmUAA() throws Exception {
serverSession.fetchSessionData(cxdxMessageFactory.createUserAuthorizationRequest());
UserAuthorizationAnswer uaa = serverSession.createUserAuthorizationAnswer();
assertNull("The Destination-Host and Destination-Realm AVPs MUST NOT be present in the answer message. [RFC3588/6.2]", uaa.getDestinationRealm());
}
use of net.java.slee.resource.diameter.cxdx.events.UserAuthorizationAnswer 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());
}
use of net.java.slee.resource.diameter.cxdx.events.UserAuthorizationAnswer 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;
}
Aggregations