use of com.ibm.cloud.sdk.core.security.Authenticator in project java-sdk by watson-developer-cloud.
the class AssistantServiceTest method setUp.
/**
* Sets up the tests.
*
* @throws Exception the exception
*/
/*
* (non-Javadoc)
* @see com.ibm.watson.common.WatsonServiceTest#setUp()
*/
@Override
@Before
public void setUp() throws Exception {
super.setUp();
String apiKey = System.getenv("ASSISTANT_APIKEY");
workspaceId = System.getenv("ASSISTANT_WORKSPACE_ID");
String serviceUrl = System.getenv("ASSISTANT_URL");
if (apiKey == null) {
apiKey = getProperty("assistant.apikey");
workspaceId = getProperty("assistant.workspace_id");
serviceUrl = getProperty("assistant.url");
}
Assume.assumeFalse("ASSISTANT_APIKEY is not defined and config.properties doesn't have valid credentials.", apiKey == null);
Authenticator authenticator = new IamAuthenticator(apiKey);
service = new Assistant("2019-02-28", authenticator);
service.setServiceUrl(serviceUrl);
service.setDefaultHeaders(getDefaultHeaders());
}
use of com.ibm.cloud.sdk.core.security.Authenticator in project java-sdk by watson-developer-cloud.
the class AssistantTest method constructClientService.
// Constructs an instance of the service to be used by the tests
public void constructClientService() {
final String serviceName = "testService";
// set mock values for global params
String version = "testString";
final Authenticator authenticator = new NoAuthAuthenticator();
assistantService = new Assistant(version, serviceName, authenticator);
String url = server.url("/").toString();
assistantService.setServiceUrl(url);
}
use of com.ibm.cloud.sdk.core.security.Authenticator in project java-sdk by watson-developer-cloud.
the class AssistantServiceTest method setUp.
/**
* Sets up the tests.
*
* @throws Exception the exception
*/
/*
* (non-Javadoc)
* @see com.ibm.watson.common.WatsonServiceTest#setUp()
*/
@Override
@Before
public void setUp() throws Exception {
super.setUp();
String apiKey = System.getenv("ASSISTANT_APIKEY");
assistantId = System.getenv("ASSISTANT_ASSISTANT_ID");
String serviceUrl = System.getenv("ASSISTANT_URL");
if (apiKey == null) {
apiKey = getProperty("assistant.apikey");
assistantId = getProperty("assistant.assistant_id");
serviceUrl = getProperty("assistant.url");
}
Assume.assumeFalse("ASSISTANT_APIKEY is not defined and config.properties doesn't have valid credentials.", apiKey == null);
Authenticator authenticator = new IamAuthenticator(apiKey);
service = new Assistant("2019-02-28", authenticator);
service.setServiceUrl(serviceUrl);
service.setDefaultHeaders(getDefaultHeaders());
}
use of com.ibm.cloud.sdk.core.security.Authenticator in project java-sdk by watson-developer-cloud.
the class DiscoveryIT method setUp.
/**
* Sets up the tests.
*
* @throws Exception the exception
*/
/*
* (non-Javadoc)
*
* @see com.ibm.watson.common.WatsonServiceTest#setUp()
*/
@Override
@Before
public void setUp() throws Exception {
super.setUp();
String apiKey = System.getenv("DISCOVERY_V2_APIKEY");
String serviceUrl = System.getenv("DISCOVERY_V2_URL");
if (apiKey == null) {
apiKey = getProperty("discovery_v2.apikey");
serviceUrl = getProperty("discovery_v2.url");
}
assertNotNull("DISCOVERY_V2_APIKEY is not defined and config.properties doesn't have valid credentials.", apiKey);
Authenticator authenticator = new IamAuthenticator(apiKey);
service = new Discovery(VERSION, authenticator);
service.setDefaultHeaders(getDefaultHeaders());
service.setServiceUrl(serviceUrl);
HttpConfigOptions configOptions = new HttpConfigOptions.Builder().disableSslVerification(true).build();
service.configureClient(configOptions);
}
use of com.ibm.cloud.sdk.core.security.Authenticator in project cloudant-java-sdk by IBM.
the class DelegatingAuthenticatorFactoryTest method getAuthenticatorForOtherAuthType.
@Test
void getAuthenticatorForOtherAuthType() {
Authenticator authenticator = DelegatingAuthenticatorFactory.getAuthenticator("test", getServicePropsWithAuthType(Authenticator.PROPNAME_AUTH_TYPE, "BASIC"));
assertFalse(authenticator instanceof CouchDbSessionAuthenticator, "Should not return " + "an instance of CouchDbSessionAuthenticator");
}
Aggregations