Skip to content

Commit

Permalink
Streamline an RBAC test (#2274)
Browse files Browse the repository at this point in the history
  • Loading branch information
drwill-ms committed Jan 11, 2022
1 parent f811e08 commit f072c94
Showing 1 changed file with 6 additions and 9 deletions.
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>();
}

#endif
Expand Down

0 comments on commit f072c94

Please sign in to comment.