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

Add additional integration tests and nightly validation #24

Merged
merged 4 commits into from
Jun 21, 2021
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
2 changes: 2 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Validate
on:
schedule:
- cron: "0 4 * * *"
pull_request:

jobs:
Expand Down
41 changes: 41 additions & 0 deletions Bandwidth.StandardTests/Messaging/GetMessagesTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Bandwidth.Standard;
using Bandwidth.Standard.Messaging.Models;
using Xunit;

namespace Bandwidth.StandardTests.Messaging
{
public class GetMessagesTests
{
private BandwidthClient _client;

public GetMessagesTests()
{
_client = new BandwidthClient.Builder()
.Environment(Bandwidth.Standard.Environment.Production)
.MessagingBasicAuthCredentials(TestConstants.Username, TestConstants.Password)
.Build();
}

[Fact]
public async Task GetMessageReturnsOK()
{
var text = "Hello from Bandwidth";

var request = new MessageRequest()
{
ApplicationId = TestConstants.MessagingApplicationId,
To = new List<string> { TestConstants.To },
From = TestConstants.From,
Text = text
};

var createMessageResponse = await _client.Messaging.APIController.CreateMessageAsync(TestConstants.AccountId, request);

var getMessagesResponse = await _client.Messaging.APIController.GetMessagesAsync(TestConstants.AccountId, createMessageResponse.Data.Id);

Assert.Equal(200, getMessagesResponse.StatusCode);
}
}
}
55 changes: 55 additions & 0 deletions Bandwidth.StandardTests/WebRtc/ParticipantTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Bandwidth.Standard;
using Bandwidth.Standard.WebRtc.Models;
using Xunit;

namespace Bandwidth.StandardTests.WebRtc
{
public class ParticipantTests
{
private BandwidthClient _client;

public ParticipantTests()
{
_client = new BandwidthClient.Builder()
.Environment(Bandwidth.Standard.Environment.Production)
.WebRtcBasicAuthCredentials(TestConstants.Username, TestConstants.Password)
.Build();
}

[Fact]
public async Task CreateParticipantWithPermissionsAsync()
{
var accountId = TestConstants.AccountId;

var participant = new Participant()
{
PublishPermissions = new List<PublishPermissionEnum>() { PublishPermissionEnum.AUDIO, PublishPermissionEnum.VIDEO }
};

var response = await _client.WebRtc.APIController.CreateParticipantAsync(accountId, participant);

Assert.Equal(200, response.StatusCode);

Assert.NotEmpty(response.Data.Participant.Id);
Assert.Null(response.Data.Participant.CallbackUrl);

Assert.Equal(2, response.Data.Participant.PublishPermissions.Count);
Assert.Contains(PublishPermissionEnum.AUDIO, response.Data.Participant.PublishPermissions);
Assert.Contains(PublishPermissionEnum.VIDEO, response.Data.Participant.PublishPermissions);

Assert.Empty(response.Data.Participant.Sessions);

Assert.Null(response.Data.Participant.Subscriptions.SessionId);
Assert.Null(response.Data.Participant.Subscriptions.Participants);

Assert.NotEmpty(response.Data.Participant.Tag);
Assert.Equal(DeviceApiVersionEnum.V2, response.Data.Participant.DeviceApiVersion);

Assert.NotEmpty(response.Data.Token);

await _client.WebRtc.APIController.DeleteParticipantAsync(accountId, response.Data.Participant.Id);
}
}
}
41 changes: 41 additions & 0 deletions Bandwidth.StandardTests/WebRtc/SessionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,46 @@ public async Task CreateSessionAndAddParticipant()
await _client.WebRtc.APIController.DeleteParticipantAsync(accountId, participantId);
await _client.WebRtc.APIController.DeleteSessionAsync(accountId, sessionId);
}

[Fact]
public async Task UpdateParticipantSubscriptionsSubscribeToParticipantAsync()
{
var accountId = TestConstants.AccountId;

var firstCreateSessionResponse = await _client.WebRtc.APIController.CreateSessionAsync(accountId);
var firstSessionId = firstCreateSessionResponse.Data.Id;

var secondCreateSessionResponse = await _client.WebRtc.APIController.CreateSessionAsync(accountId);
var secondSessionId = secondCreateSessionResponse.Data.Id;

// Assign the existing first session to the participant as a subscription.
var participant = new Participant()
{
PublishPermissions = new List<PublishPermissionEnum>() { PublishPermissionEnum.AUDIO, PublishPermissionEnum.VIDEO },
Subscriptions = new Subscriptions
{
SessionId = firstSessionId
}
};

var createParticipantResponse = await _client.WebRtc.APIController.CreateParticipantAsync(accountId, participant);
var participantId = createParticipantResponse.Data.Participant.Id;

var subscriptions = new Subscriptions
{
SessionId = secondSessionId
};

await _client.WebRtc.APIController.UpdateParticipantSubscriptionsAsync(accountId, participantId, secondSessionId, subscriptions);

var getParticipantSubscriptionsResponse = await _client.WebRtc.APIController.GetParticipantSubscriptionsAsync(accountId, participantId, secondSessionId);

Assert.Equal(secondSessionId, getParticipantSubscriptionsResponse.Data.SessionId);

// Cleanup participant and sessions.
await _client.WebRtc.APIController.DeleteParticipantAsync(accountId, participantId);
await _client.WebRtc.APIController.DeleteSessionAsync(accountId, firstSessionId);
await _client.WebRtc.APIController.DeleteSessionAsync(accountId, secondSessionId);
}
}
}