Skip to content

Commit

Permalink
Get rid of password flow in test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerlong committed Oct 3, 2023
1 parent 5f4de55 commit aed77f6
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 129 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
RINGCENTRAL_CLIENT_ID: ${{ secrets.RINGCENTRAL_CLIENT_ID }}
RINGCENTRAL_CLIENT_SECRET: ${{ secrets.RINGCENTRAL_CLIENT_SECRET }}
RINGCENTRAL_USERNAME: ${{ secrets.RINGCENTRAL_USERNAME }}
RINGCENTRAL_EXTENSION: ${{ secrets.RINGCENTRAL_EXTENSION }}
RINGCENTRAL_PASSWORD: ${{ secrets.RINGCENTRAL_PASSWORD }}
RINGCENTRAL_JWT_TOKEN: ${{ secrets.RINGCENTRAL_JWT_TOKEN }}
RINGCENTRAL_RECEIVER: ${{ secrets.RINGCENTRAL_RECEIVER }}
RINGCENTRAL_CALLEE: ${{ secrets.RINGCENTRAL_CALLEE }}
7 changes: 0 additions & 7 deletions dev-notes.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
## Setup

```
cp src/test/resources/.env.sample src/test/resources/.env
edit src/test/resources/.env
```

## Test

```
Expand Down
6 changes: 1 addition & 5 deletions src/test/java/com/ringcentral/AuthorizationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ public void testAuthorize() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

TokenInfo token = rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
TokenInfo token = rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));
assertNotNull(token.access_token);
assertNotNull(rc.token);
rc.revoke();
Expand Down
12 changes: 3 additions & 9 deletions src/test/java/com/ringcentral/BinaryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ public void uploadProfileImage() throws IOException, RestException {
System.getenv("RINGCENTRAL_CLIENT_SECRET"),
System.getenv("RINGCENTRAL_SERVER_URL"));

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD"));
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

String str = rc.restapi().account().extension().profileImage().post(new
rc.restapi().account().extension().profileImage().post(new
CreateUserProfileImageRequest()
.image(new Attachment()
.filename("test.png")
Expand All @@ -40,10 +37,7 @@ public void downloadProfileImage() throws IOException, RestException {
System.getenv("RINGCENTRAL_CLIENT_SECRET"),
System.getenv("RINGCENTRAL_SERVER_URL"));

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD"));
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

byte[] bytes =
rc.restapi().account().extension().profileImage("90x90").get();
Expand Down
6 changes: 1 addition & 5 deletions src/test/java/com/ringcentral/CallLogTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ public void listCallLogs() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

ReadUserCallLogParameters getParameters = new ReadUserCallLogParameters();

Expand Down
6 changes: 1 addition & 5 deletions src/test/java/com/ringcentral/CheckSubscriptionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ public void listSubscriptions() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

SubscriptionListResource resp = rc.restapi().subscription().list();
for (SubscriptionInfo r : resp.records) {
Expand Down
13 changes: 2 additions & 11 deletions src/test/java/com/ringcentral/ConsumeTextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,10 @@ public void updateGlipPostText() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

String groupId = rc.teamMessaging().v1().chats().list().records[0].id;
String postId = rc.teamMessaging().v1().chats(groupId).posts().list().records[0].id;

// below is for experiment only
// String newText = UUID.randomUUID().toString();
// String updatedText = rc.restapi().glip().groups(groupId).posts(postId).text().put(newText);
// assertEquals(updatedText, newText);
rc.teamMessaging().v1().chats(groupId).posts().list();

rc.revoke();
}
Expand Down
12 changes: 2 additions & 10 deletions src/test/java/com/ringcentral/DictionaryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ public void testGetCountry() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

CountryInfoDictionaryModel c = rc.restapi().dictionary().country("46").get();
Assert.assertEquals("China", c.name);
Expand All @@ -36,11 +32,7 @@ public void testListCountry() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

CountryListDictionaryModel r = rc.restapi().dictionary().country().list();
Assert.assertTrue(r.records.length > 0);
Expand Down
6 changes: 1 addition & 5 deletions src/test/java/com/ringcentral/FaxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ public void sendFax() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

FaxResponse r = rc.restapi().account().extension().fax().post(
new CreateFaxMessageRequest()
Expand Down
6 changes: 1 addition & 5 deletions src/test/java/com/ringcentral/HttpEventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ public void afterHttpCall() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

final int[] count = {0};
rc.httpEventListeners.add((response, request) -> {
Expand Down
18 changes: 3 additions & 15 deletions src/test/java/com/ringcentral/IVRContentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ public void downloadIVRPromptContent() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

IvrPrompts ivrPrompts = rc.restapi().account().ivrPrompts().list();
PromptInfo promptInfo = rc.restapi().account().ivrPrompts(ivrPrompts.records[0].id).get();
Expand All @@ -41,11 +37,7 @@ public void createIVRPromptContent() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

rc.restapi().account().ivrPrompts().post(new CreateIVRPromptRequest()
.name("Uploaded via API")
Expand All @@ -66,11 +58,7 @@ public void updateIVRPromptContent() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

IvrPrompts ivrPrompts = rc.restapi().account().ivrPrompts().list();
PromptInfo promptInfo = rc.restapi().account().ivrPrompts(ivrPrompts.records[0].id).get();
Expand Down
6 changes: 1 addition & 5 deletions src/test/java/com/ringcentral/LowLevelAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ public void testParseObject() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));
ResponseBody responseBody = rc.get("/restapi/v1.0/account/~/extension/~", null);
String responseString = responseBody.string();
GetExtensionInfoResponse extensionInfo = Utils.gson.fromJson(responseString, GetExtensionInfoResponse.class);
Expand Down
6 changes: 1 addition & 5 deletions src/test/java/com/ringcentral/MmsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ public void sendMms() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

GetSMSMessageInfoResponse response = rc.restapi().account().extension().mms().post(
new CreateMMSMessage()
Expand Down
6 changes: 1 addition & 5 deletions src/test/java/com/ringcentral/ProvisionExtensionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ public void CreateAndDeleteExtension() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

rc.httpEventListeners.add((response, request) -> {
String message = Utils.formatHttpMessage(response, request);
Expand Down
6 changes: 1 addition & 5 deletions src/test/java/com/ringcentral/ProvisionIvrMenuTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ public void CreateAndDeleteIVRMenu() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

IVRMenuInfo iVRMenuInfo = rc.restapi().account().ivrMenus().post(new IVRMenuInfo().extensionNumber("2002").name("My IVR menu"));
assertNotNull(iVRMenuInfo);
Expand Down
12 changes: 2 additions & 10 deletions src/test/java/com/ringcentral/SmsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ public void sendSms() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

GetSMSMessageInfoResponse response = rc.restapi().account().extension().sms().post(
new CreateSMSMessage()
Expand All @@ -48,11 +44,7 @@ public void sendSms2() throws IOException, RestException {
System.getenv("RINGCENTRAL_SERVER_URL")
);

rc.authorize(
System.getenv("RINGCENTRAL_USERNAME"),
System.getenv("RINGCENTRAL_EXTENSION"),
System.getenv("RINGCENTRAL_PASSWORD")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));

CreateSMSMessage requestBody = new CreateSMSMessage();
requestBody.text = "hello world";
Expand Down
20 changes: 0 additions & 20 deletions src/test/java/com/ringcentral/V2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,5 @@ public void GetAccountInfo() throws IOException, RestException {
);
String path = rc.restapi().v2().accounts().path();
Assert.assertEquals("/restapi/v2/accounts/~", path);
//
// rc.authorize(
// System.getenv("RINGCENTRAL_USERNAME"),
// System.getenv("RINGCENTRAL_EXTENSION"),
// System.getenv("RINGCENTRAL_PASSWORD")
// );
//
// GetSMSMessageInfoResponse response = rc.restapi().account().extension().sms().post(
// new CreateSMSMessage()
// .text("hello world")
// .from(new MessageStoreCallerInfoRequest().phoneNumber(System.getenv("RINGCENTRAL_USERNAME")))
// .to(new MessageStoreCallerInfoRequest[]{
// new MessageStoreCallerInfoRequest().phoneNumber(System.getenv("RINGCENTRAL_RECEIVER"))
// })
// );
// assertNotNull(response);
// assertNotNull(response.subject);
// assertTrue(response.subject.contains("hello world"));
//
// rc.revoke();
}
}

0 comments on commit aed77f6

Please sign in to comment.