8000 feat: Adding test cases for public oauth uptake (#767) · twilio/twilio-csharp@9063939 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9063939

Browse files
authored
feat: Adding test cases for public oauth uptake (#767)
* Adding test cases for public oauth uptake
1 parent b6aabe9 commit 9063939

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/Twilio.Test/ClusterTest.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Twilio.Rest.Events.V1;
99
using Twilio.Rest.PreviewIam;
1010
using System.Linq;
11+
using Twilio.Credential;
1112
namespace Twilio.Tests
1213
{
1314
[TestFixture]
@@ -21,6 +22,10 @@ class ClusterTest
2122
string orgsSid;
2223
string clientId;
2324
string clientSecret;
25+
string oAuthClientId;
26+
string oAuthClientSecret;
27+
string oAuthMessageId;
28+
2429
[SetUp]
2530
[Category("ClusterTest")]
2631
public void SetUp()
@@ -33,6 +38,10 @@ public void SetUp()
3338
orgsSid = Environment.GetEnvironmentVariable("TWILIO_ORG_SID");
3439
clientId = Environment.GetEnvironmentVariable("TWILIO_ORGS_CLIENT_ID");
3540
clientSecret = Environment.GetEnvironmentVariable("TWILIO_ORGS_CLIENT_SECRET");
41+
42+
oAuthClientId = Environment.GetEnvironmentVariable("TWILIO_CLIENT_ID");
43+
oAuthClientSecret = Environment.GetEnvironmentVariable("TWILIO_CLIENT_SECRET");
44+
oAuthMessageId = Environment.GetEnvironmentVariable("TWILIO_MESSAGE_SID");
3645
TwilioClient.Init(username:apiKey,password:secret,accountSid:accountSid);
3746
TwilioOrgsTokenAuthClient.Init(clientId, clientSecret);
3847
}
@@ -143,5 +152,22 @@ public void TestFetchingOrgsAccounts()
143152
Assert.IsNotNull(userList);
144153

145154
}
155+
156+
[Test]
157+
[Category("ClusterTest")]
158+
public void TestPublicOAuth()
159+
{
160+
161+
CredentialProvider cp = new ClientCredentialProvider(oAuthClientId,oAuthClientSecret);
162+
TwilioClient.SetAccountSid(accountSid);
163+
TwilioClient.Init(cp, accountSid);
164+
165+
// Fetching an existing message; if this test fails, the SID might be deleted,
166+
// in that case, change TWILIO_MESSAGE_SID in twilio-csharp repo env variables
167+
FetchMessageOptions fm = new FetchMessageOptions(oAuthMessageId);
168+
MessageResource m = MessageResource.Fetch(fm);
169+
Assert.IsNotNull(m.Body);
170+
171+
}
146172
}
147173
}

0 commit comments

Comments
 (0)
0