From 0f40b9d517f55ad56ece53d1e2a614f1909ac5b5 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Fri, 28 Jun 2024 09:31:22 +0530 Subject: [PATCH] adding cluster tests for orgs api --- src/test/java/com/twilio/ClusterTest.java | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/test/java/com/twilio/ClusterTest.java b/src/test/java/com/twilio/ClusterTest.java index 93a92c4cad..a4dc2e5337 100644 --- a/src/test/java/com/twilio/ClusterTest.java +++ b/src/test/java/com/twilio/ClusterTest.java @@ -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; @@ -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() { @@ -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 @@ -107,4 +121,24 @@ public void testListParams() { assertTrue(Sink.deleter(sink.getSid()).delete()); } + @Test + public void testOrgsApi(){ + + //Fetching the account information + ResourceSet 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 + userSet = com.twilio.rest.previewiam.organizations.User.reader(organisationSid).read(); + assertNotNull(userSet); + String userId = userSet.iterator().next().getId().toString(); + assertNotNull(userId); + } + }