Skip to content

Commit 9cc9058

Browse files
committed
update tests to use new client id and secret
1 parent 0ec2744 commit 9cc9058

15 files changed

+31
-440
lines changed

sdfg

Whitespace-only changes.

src/test/java/com/bandwidth/sdk/smoke/CallsApiTest.java

Lines changed: 3 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import com.bandwidth.sdk.ApiResponse;
55
import com.bandwidth.sdk.ApiException;
66
import com.bandwidth.sdk.ApiClient;
7-
import com.bandwidth.sdk.auth.HttpBasicAuth;
8-
import com.bandwidth.sdk.Configuration;
97
import com.bandwidth.sdk.model.CallbackMethodEnum;
108
import com.bandwidth.sdk.model.CreateCall;
119
import com.bandwidth.sdk.model.CreateCallResponse;
@@ -40,12 +38,12 @@
4038
import static com.bandwidth.sdk.utils.TestingEnvironmentVariables.*;
4139
import static com.bandwidth.sdk.utils.CallCleanup.Cleanup;
4240

41+
@SuppressWarnings("null")
4342
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
4443
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
4544
public class CallsApiTest {
46-
public ApiClient defaultClient = Configuration.getDefaultApiClient();
47-
public HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
48-
public final CallsApi api = new CallsApi(defaultClient);
45+
private static ApiClient oauthClient = new ApiClient(BW_CLIENT_ID, BW_CLIENT_SECRET, null);
46+
public final CallsApi api = new CallsApi(oauthClient);
4947

5048
private static List<String> callIdList = new ArrayList<String>();
5149
private static MachineDetectionConfiguration machineDetection = new MachineDetectionConfiguration();
@@ -132,9 +130,6 @@ public void tearDownAfterClass() throws Exception {
132130
@Test
133131
@Order(1)
134132
public void createCall() throws ApiException {
135-
Basic.setUsername(BW_USERNAME);
136-
Basic.setPassword(BW_PASSWORD);
137-
138133
ApiResponse<CreateCallResponse> response = api.createCallWithHttpInfo(BW_ACCOUNT_ID, createCallBody);
139134
callIdList.add(response.getData().getCallId());
140135

@@ -148,9 +143,6 @@ public void createCall() throws ApiException {
148143

149144
@Test
150145
public void createCallBadRequest() throws ApiException {
151-
Basic.setUsername(BW_USERNAME);
152-
Basic.setPassword(BW_PASSWORD);
153-
154146
CreateCall badCallRequest = new CreateCall();
155147
createCallBody.setTo("invalid_number");
156148
createCallBody.setFrom(BW_NUMBER);
@@ -163,45 +155,8 @@ public void createCallBadRequest() throws ApiException {
163155
assertThat(exception.getCode(), is(400));
164156
}
165157

166-
@Test
167-
public void createCallUnauthorized() throws ApiException {
168-
Basic.setUsername("bad_username");
169-
Basic.setPassword("bad_password");
170-
171-
CreateCall badCallRequest = new CreateCall();
172-
createCallBody.setTo("invalid_number");
173-
createCallBody.setFrom(BW_NUMBER);
174-
createCallBody.setApplicationId(BW_VOICE_APPLICATION_ID);
175-
createCallBody.setAnswerUrl(answerUrl);
176-
177-
ApiException exception = Assertions.assertThrows(ApiException.class,
178-
() -> api.createCallWithHttpInfo(BW_ACCOUNT_ID, badCallRequest));
179-
180-
assertThat(exception.getCode(), is(401));
181-
}
182-
183-
@Test
184-
public void createCallForbidden() throws ApiException {
185-
Basic.setUsername(FORBIDDEN_USERNAME);
186-
Basic.setPassword(FORBIDDEN_PASSWORD);
187-
188-
CreateCall badCallRequest = new CreateCall();
189-
createCallBody.setTo("invalid_number");
190-
createCallBody.setFrom(BW_NUMBER);
191-
createCallBody.setApplicationId(BW_VOICE_APPLICATION_ID);
192-
createCallBody.setAnswerUrl(answerUrl);
193-
194-
ApiException exception = Assertions.assertThrows(ApiException.class,
195-
() -> api.createCallWithHttpInfo(BW_ACCOUNT_ID, badCallRequest));
196-
197-
assertThat(exception.getCode(), is(403));
198-
}
199-
200158
@Test
201159
public void getCalls() throws ApiException {
202-
Basic.setUsername(BW_USERNAME);
203-
Basic.setPassword(BW_PASSWORD);
204-
205160
ApiResponse<List<CallState>> response = api.listCallsWithHttpInfo(BW_ACCOUNT_ID, USER_NUMBER, BW_NUMBER, null,
206161
null, null, null, null);
207162

@@ -220,9 +175,6 @@ public void getCalls() throws ApiException {
220175
@Test
221176
@Order(2)
222177
public void getCallState() throws ApiException, InterruptedException {
223-
Basic.setUsername(BW_USERNAME);
224-
Basic.setPassword(BW_PASSWORD);
225-
226178
TimeUnit.SECONDS.sleep(40);
227179
ApiResponse<CallState> response = api.getCallStateWithHttpInfo(BW_ACCOUNT_ID, callIdList.get(0));
228180

@@ -232,33 +184,8 @@ public void getCallState() throws ApiException, InterruptedException {
232184
assertThat(response.getData(), hasProperty("direction", is(CallDirectionEnum.OUTBOUND)));
233185
}
234186

235-
@Test
236-
public void getCallStateUnauthorized() throws ApiException {
237-
Basic.setUsername("bad_username");
238-
Basic.setPassword("bad_password");
239-
240-
ApiException exception = Assertions.assertThrows(ApiException.class,
241-
() -> api.getCallStateWithHttpInfo(BW_ACCOUNT_ID, "not a call id"));
242-
243-
assertThat(exception.getCode(), is(401));
244-
}
245-
246-
@Test
247-
public void getCallStateForbidden() throws ApiException {
248-
Basic.setUsername(FORBIDDEN_USERNAME);
249-
Basic.setPassword(FORBIDDEN_PASSWORD);
250-
251-
ApiException exception = Assertions.assertThrows(ApiException.class,
252-
() -> api.getCallStateWithHttpInfo(BW_ACCOUNT_ID, "not a call id"));
253-
254-
assertThat(exception.getCode(), is(403));
255-
}
256-
257187
@Test
258188
public void getCallStateNotFound() throws ApiException {
259-
Basic.setUsername(BW_USERNAME);
260-
Basic.setPassword(BW_PASSWORD);
261-
262189
ApiException exception = Assertions.assertThrows(ApiException.class,
263190
() -> api.getCallStateWithHttpInfo(BW_ACCOUNT_ID, "not a call id"));
264191

@@ -268,9 +195,6 @@ public void getCallStateNotFound() throws ApiException {
268195
@Test
269196
@Order(3)
270197
public void updateCall() throws ApiException, InterruptedException {
271-
Basic.setUsername(BW_USERNAME);
272-
Basic.setPassword(BW_PASSWORD);
273-
274198
// Create call
275199
TimeUnit.SECONDS.sleep(TEST_SLEEP);
276200
ApiResponse<CreateCallResponse> createCallResponse = api.createCallWithHttpInfo(BW_ACCOUNT_ID,
@@ -296,9 +220,6 @@ public void updateCall() throws ApiException, InterruptedException {
296220

297221
@Test
298222
public void updateCallBadRequest() throws ApiException, InterruptedException {
299-
Basic.setUsername(BW_USERNAME);
300-
Basic.setPassword(BW_PASSWORD);
301-
302223
UpdateCall badRequest = new UpdateCall();
303224
badRequest.state(null);
304225

@@ -314,36 +235,8 @@ public void updateCallBadRequest() throws ApiException, InterruptedException {
314235
assertThat(exception.getCode(), is(400));
315236
}
316237

317-
@Test
318-
public void updateCallUnauthorized() throws ApiException {
319-
Basic.setUsername("bad_username");
320-
Basic.setPassword("bad_password");
321-
322-
ApiException exception = Assertions.assertThrows(ApiException.class,
323-
() -> api.updateCallWithHttpInfo(BW_ACCOUNT_ID, testCallId,
324-
new UpdateCall().state(CallStateEnum.COMPLETED)));
325-
326-
assertThat(exception.getCode(), is(401));
327-
328-
}
329-
330-
@Test
331-
public void updateCallForbidden() throws ApiException {
332-
Basic.setUsername(FORBIDDEN_USERNAME);
333-
Basic.setPassword(FORBIDDEN_PASSWORD);
334-
335-
ApiException exception = Assertions.assertThrows(ApiException.class,
336-
() -> api.updateCallWithHttpInfo(BW_ACCOUNT_ID, testCallId,
337-
new UpdateCall().state(CallStateEnum.COMPLETED)));
338-
339-
assertThat(exception.getCode(), is(403));
340-
}
341-
342238
@Test
343239
public void updateCallNotFound() throws ApiException {
344-
Basic.setUsername(BW_USERNAME);
345-
Basic.setPassword(BW_PASSWORD);
346-
347240
ApiException exception = Assertions.assertThrows(ApiException.class,
348241
() -> api.updateCallWithHttpInfo(BW_ACCOUNT_ID, testCallId,
349242
new UpdateCall().state(CallStateEnum.COMPLETED)));
@@ -354,9 +247,6 @@ public void updateCallNotFound() throws ApiException {
354247
@Test
355248
@Order(4)
356249
public void updateCallBxml() throws ApiException, InterruptedException {
357-
Basic.setUsername(BW_USERNAME);
358-
Basic.setPassword(BW_PASSWORD);
359-
360250
// Create call
361251
TimeUnit.SECONDS.sleep(TEST_SLEEP);
362252
ApiResponse<CreateCallResponse> createCallResponse = api.createCallWithHttpInfo(BW_ACCOUNT_ID,
@@ -379,45 +269,4 @@ public void updateCallBxml() throws ApiException, InterruptedException {
379269

380270
assertThat(completeCallResponse.getStatusCode(), is(200));
381271
}
382-
383-
@Test
384-
public void updateCallBxmlBadRequest() throws ApiException {
385-
386-
}
387-
388-
@Test
389-
public void updateCallBxmlUnauthorized() throws ApiException {
390-
Basic.setUsername("bad_username");
391-
Basic.setPassword("bad_password");
392-
393-
ApiException exception = Assertions.assertThrows(ApiException.class,
394-
() -> api.updateCallBxmlWithHttpInfo(BW_ACCOUNT_ID, testCallId,
395-
testXmlBody));
396-
397-
assertThat(exception.getCode(), is(401));
398-
}
399-
400-
@Test
401-
public void updateCallBxmlForbidden() throws ApiException {
402-
Basic.setUsername(FORBIDDEN_USERNAME);
403-
Basic.setPassword(FORBIDDEN_PASSWORD);
404-
405-
ApiException exception = Assertions.assertThrows(ApiException.class,
406-
() -> api.updateCallBxmlWithHttpInfo(BW_ACCOUNT_ID, testCallId,
407-
testXmlBody));
408-
409-
assertThat(exception.getCode(), is(403));
410-
}
411-
412-
@Test
413-
public void updateCallBxmlNotFound() throws ApiException {
414-
Basic.setUsername(BW_USERNAME);
415-
Basic.setPassword(BW_PASSWORD);
416-
417-
ApiException exception = Assertions.assertThrows(ApiException.class,
418-
() -> api.updateCallBxmlWithHttpInfo(BW_ACCOUNT_ID, testCallId,
419-
testXmlBody));
420-
421-
assertThat(exception.getCode(), is(404));
422-
}
423272
}

src/test/java/com/bandwidth/sdk/smoke/ConferencesApiTest.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import com.bandwidth.sdk.api.ConferencesApi;
55
import com.bandwidth.sdk.ApiResponse;
66
import com.bandwidth.sdk.ApiClient;
7-
import com.bandwidth.sdk.auth.HttpBasicAuth;
8-
import com.bandwidth.sdk.Configuration;
97
import com.bandwidth.sdk.model.ConferenceRecordingMetadata;
108
import com.bandwidth.sdk.model.ConferenceStateEnum;
119
import com.bandwidth.sdk.model.CreateCall;
@@ -48,13 +46,13 @@
4846
import static com.bandwidth.sdk.utils.TestingEnvironmentVariables.*;
4947
import static com.bandwidth.sdk.utils.CallCleanup.Cleanup;
5048

49+
@SuppressWarnings("null")
5150
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
5251
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
5352
public class ConferencesApiTest {
54-
public ApiClient defaultClient = Configuration.getDefaultApiClient();
55-
public HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
56-
public final CallsApi callsApi = new CallsApi(defaultClient);
57-
public final ConferencesApi conferencesApi = new ConferencesApi(defaultClient);
53+
private static ApiClient oauthClient = new ApiClient(BW_CLIENT_ID, BW_CLIENT_SECRET, null);
54+
public final CallsApi callsApi = new CallsApi(oauthClient);
55+
public final ConferencesApi conferencesApi = new ConferencesApi(oauthClient);
5856

5957
private static final OkHttpClient mantecaClient = new OkHttpClient();
6058
public static final MediaType jsonMediaType = MediaType.get("application/json; charset=utf-8");
@@ -118,9 +116,6 @@ public Boolean getTestRecordedStatus(String mantecaTestId) throws Exception {
118116
@Test
119117
@Order(1)
120118
public void testCreateAndFetchConference() throws Exception {
121-
Basic.setUsername(BW_USERNAME);
122-
Basic.setPassword(BW_PASSWORD);
123-
124119
String mantecaJsonBody = constructMantecaJsonBody(OPERATING_SYSTEM, JAVA_VERSION);
125120
RequestBody mantecaRequestBody = RequestBody.create(mantecaJsonBody, jsonMediaType);
126121

@@ -171,9 +166,6 @@ public void testCreateAndFetchConference() throws Exception {
171166
@Test
172167
@Order(2)
173168
public void testConferenceAndMembers() throws Exception {
174-
Basic.setUsername(BW_USERNAME);
175-
Basic.setPassword(BW_PASSWORD);
176-
177169
ApiResponse<ConferenceMember> listConferenceMembersResponse = conferencesApi
178170
.getConferenceMemberWithHttpInfo(BW_ACCOUNT_ID, conferenceId, callId);
179171
assertThat(listConferenceMembersResponse.getStatusCode(), is(200));
@@ -210,9 +202,6 @@ public void testConferenceAndMembers() throws Exception {
210202
@Order(3)
211203
@Disabled // issues with PV API, can re-enable after fixed
212204
public void testConferenceRecordings() throws Exception {
213-
Basic.setUsername(BW_USERNAME);
214-
Basic.setPassword(BW_PASSWORD);
215-
216205
Boolean testRecordingStatus = false;
217206
for (int i = 0; i < MAX_RETRIES; i++) {
218207
TimeUnit.SECONDS.sleep(TEST_SLEEP);

src/test/java/com/bandwidth/sdk/smoke/PhoneNumberLookupApiTest.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import com.bandwidth.sdk.ApiResponse;
55
import com.bandwidth.sdk.ApiException;
66
import com.bandwidth.sdk.ApiClient;
7-
import com.bandwidth.sdk.auth.HttpBasicAuth;
8-
import com.bandwidth.sdk.Configuration;
97
import com.bandwidth.sdk.model.AsyncLookupRequest;
108
import com.bandwidth.sdk.model.CompletedLookupStatusEnum;
119
import com.bandwidth.sdk.model.CreateAsyncBulkLookupResponse;
@@ -36,17 +34,12 @@
3634

3735
@SuppressWarnings("null")
3836
public class PhoneNumberLookupApiTest {
39-
40-
ApiClient defaultClient = Configuration.getDefaultApiClient();
41-
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
42-
private final PhoneNumberLookupApi api = new PhoneNumberLookupApi(defaultClient);
37+
private static ApiClient oauthClient = new ApiClient(BW_CLIENT_ID, BW_CLIENT_SECRET, null);
38+
private final PhoneNumberLookupApi api = new PhoneNumberLookupApi(oauthClient);
4339
private final List<String> phoneNumbers = Arrays.asList(BW_NUMBER, VZW_NUMBER, ATT_NUMBER, T_MOBILE_NUMBER);
4440

4541
@Test
4642
public void createSyncLookupTest() throws ApiException {
47-
Basic.setUsername(BW_USERNAME);
48-
Basic.setPassword(BW_PASSWORD);
49-
5043
SyncLookupRequest lookupRequest = new SyncLookupRequest()
5144
.phoneNumbers(phoneNumbers);
5245

@@ -70,9 +63,6 @@ public void createSyncLookupTest() throws ApiException {
7063

7164
@Test
7265
public void createGetAsyncLookupTest() throws ApiException, InterruptedException {
73-
Basic.setUsername(BW_USERNAME);
74-
Basic.setPassword(BW_PASSWORD);
75-
7666
AsyncLookupRequest lookupRequest = new AsyncLookupRequest()
7767
.phoneNumbers(phoneNumbers);
7868

0 commit comments

Comments
 (0)