Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adding cluster tests for orgs api #804

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ jobs:
TWILIO_API_SECRET: ${{ secrets.TWILIO_CLUSTER_TEST_API_KEY_SECRET }}
TWILIO_FROM_NUMBER: ${{ secrets.TWILIO_FROM_NUMBER }}
TWILIO_TO_NUMBER: ${{ secrets.TWILIO_TO_NUMBER }}
TWILIO_ORGS_CLIENT_ID: ${{ secrets.TWILIO_ORGS_CLIENT_ID }}
TWILIO_ORGS_CLIENT_SECRET: ${{ secrets.TWILIO_ORGS_CLIENT_SECRET }}
TWILIO_ORG_SID: ${{ secrets.TWILIO_ORG_SID }}
run: mvn test -DTest="ClusterTest" -B

- uses: actions/setup-java@v4
Expand Down
34 changes: 34 additions & 0 deletions src/test/java/com/twilio/ClusterTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.twilio;

import com.twilio.base.Page;

import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumberReader;
import com.twilio.rest.api.v2010.account.Message;
Expand All @@ -20,9 +21,16 @@

import static org.junit.Assert.*;

import com.twilio.rest.previewiam.organizations.Account;
import com.twilio.base.bearertoken.ResourceSet;

public class ClusterTest {
String fromNumber;
String toNumber;
String grantType;
String clientId;
String clientSecret;
String organisationSid;

@Before
public void setUp() {
Expand All @@ -34,6 +42,12 @@ public void setUp() {
String secret = System.getenv("TWILIO_API_SECRET");
String accountSid = System.getenv("TWILIO_ACCOUNT_SID");
Twilio.init(apiKey, secret, accountSid);

grantType = "client_credentials";
clientId = System.getenv("TWILIO_ORGS_CLIENT_ID");
clientSecret = System.getenv("TWILIO_ORGS_CLIENT_SECRET");
organisationSid = System.getenv("TWILIO_ORG_SID");
TwilioOrgsTokenAuth.init(grantType, clientId, clientSecret);
}

@Test
Expand Down Expand Up @@ -107,4 +121,24 @@ public void testListParams() {
assertTrue(Sink.deleter(sink.getSid()).delete());
}

@Test
public void testOrgsApi(){

//Fetching the account information
ResourceSet<Account> accountSet = Account.reader(organisationSid).read();
String accountSid = accountSet.iterator().next().getAccountSid();
assertNotNull(accountSid);

//Fetching specific account
Account account = Account.fetcher(organisationSid, accountSid).fetch();
assertNotNull(account.getAccountSid());

//Fetching users of this organisation
ResourceSet<com.twilio.rest.previewiam.organizations.User>
userSet = com.twilio.rest.previewiam.organizations.User.reader(organisationSid).read();
assertNotNull(userSet);
String userId = userSet.iterator().next().getId().toString();
assertNotNull(userId);
}

}
Loading