use of com.netsuite.webservices.test.platform.core.Passport in project components by Talend.
the class TestNetSuiteClientService method createNativePassport.
@Override
protected Passport createNativePassport(NetSuiteCredentials nsCredentials) {
RecordRef roleRecord = new RecordRef();
roleRecord.setInternalId(nsCredentials.getRoleId());
final Passport passport = new Passport();
passport.setEmail(nsCredentials.getEmail());
passport.setPassword(nsCredentials.getPassword());
passport.setRole(roleRecord);
passport.setAccount(nsCredentials.getAccount());
return passport;
}
use of com.netsuite.webservices.test.platform.core.Passport in project components by Talend.
the class TestNetSuiteClientService method doLogin.
@Override
protected void doLogin() throws NetSuiteException {
port = getNetSuitePort(endpointUrl, credentials.getAccount());
setHttpClientPolicy(port);
setLoginHeaders(port);
PortOperation<SessionResponse, NetSuitePortType> loginOp;
if (!credentials.isUseSsoLogin()) {
final Passport passport = createNativePassport(credentials);
loginOp = new PortOperation<SessionResponse, NetSuitePortType>() {
@Override
public SessionResponse execute(NetSuitePortType port) throws Exception {
LoginRequest request = new LoginRequest();
request.setPassport(passport);
LoginResponse response = port.login(request);
return response.getSessionResponse();
}
};
} else {
throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR), NetSuiteRuntimeI18n.MESSAGES.getMessage("error.ssoLoginNotSupported"));
}
Status status = null;
SessionResponse sessionResponse;
String exceptionMessage = null;
for (int i = 0; i < getRetryCount(); i++) {
try {
sessionResponse = loginOp.execute(port);
status = sessionResponse.getStatus();
} catch (InvalidCredentialsFault f) {
throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR), f.getFaultInfo().getMessage());
} catch (UnexpectedErrorFault f) {
exceptionMessage = f.getFaultInfo().getMessage();
} catch (Exception e) {
exceptionMessage = e.getMessage();
}
if (status != null) {
break;
}
if (i != getRetryCount() - 1) {
waitForRetryInterval();
}
}
checkLoginError(toNsStatus(status), exceptionMessage);
removeLoginHeaders(port);
}
use of com.netsuite.webservices.test.platform.core.Passport in project components by Talend.
the class NetSuiteClientServiceTest method testLogin.
@Test
public void testLogin() throws Exception {
clientService.login();
verify(port, times(1)).login(argThat(new AssertMatcher<LoginRequest>() {
@Override
protected void doAssert(LoginRequest request) throws Exception {
assertNotNull(request);
Passport passport = request.getPassport();
assertNotNull(passport);
}
}));
// Verify that logging in not performed for already logged in client
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("RecordRef");
RecordRef recordRef = new NsObjectComposer<RecordRef>(clientService.getMetaDataSource(), typeDesc).composeObject();
DeleteResponse response = new DeleteResponse();
response.setWriteResponse(createSuccessWriteResponse());
when(port.delete(notNull(DeleteRequest.class))).thenReturn(response);
clientService.delete(recordRef);
verify(port, times(1)).login(any(LoginRequest.class));
}
Aggregations