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

Streamline an RBAC test #2274

Merged
merged 4 commits into from
Jan 11, 2022
Merged
Changes from 2 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
15 changes: 6 additions & 9 deletions e2e/test/iothub/TokenCredentialAuthenticationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,19 @@ public async Task DigitalTwinClient_Http_TokenCredentialAuth_Success()
public async Task Service_Amqp_TokenCredentialAuth_Success()
{
// arrange
TestDevice testDevice = await TestDevice.GetTestDeviceAsync(Logger, _devicePrefix).ConfigureAwait(false);
using DeviceClient deviceClient = testDevice.CreateDeviceClient(Client.TransportType.Mqtt);
await deviceClient.OpenAsync().ConfigureAwait(false);

string ghostDevice = $"{nameof(Service_Amqp_TokenCredentialAuth_Success)}_{Guid.NewGuid()}";
using var serviceClient = ServiceClient.Create(
TestConfiguration.IoTHub.GetIotHubHostName(),
TestConfiguration.IoTHub.GetClientSecretCredential(),
TransportType.Amqp);

// act
await serviceClient.OpenAsync().ConfigureAwait(false);
using var message = new Message(Encoding.ASCII.GetBytes("Hello, Cloud!"));
await serviceClient.SendAsync(testDevice.Id, message);

// cleanup
await testDevice.RemoveDeviceAsync().ConfigureAwait(false);
// act
Func<Task> act = async () => await serviceClient.SendAsync(ghostDevice, message).ConfigureAwait(false);

// assert
await act.Should().ThrowAsync<DeviceNotFoundException>();
drwill-ms marked this conversation as resolved.
Show resolved Hide resolved
}

#endif
Expand Down