Skip to content

Commit

Permalink
adding cluster tests for orgs api
Browse files Browse the repository at this point in the history
  • Loading branch information
AsabuHere committed Jun 28, 2024
1 parent eecc0cb commit 0f40b9d
Showing 1 changed file with 34 additions and 0 deletions.
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);
}

}

0 comments on commit 0f40b9d

Please sign in to comment.