From 5c4d52364f931a0257e2606123362dff591a8f49 Mon Sep 17 00:00:00 2001 From: "David R. Williamson" Date: Mon, 10 Jan 2022 13:44:54 -0800 Subject: [PATCH] Streamline an RBAC test --- .../iothub/TokenCredentialAuthenticationTests.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/e2e/test/iothub/TokenCredentialAuthenticationTests.cs b/e2e/test/iothub/TokenCredentialAuthenticationTests.cs index c7270ef85b..6c1e687b76 100644 --- a/e2e/test/iothub/TokenCredentialAuthenticationTests.cs +++ b/e2e/test/iothub/TokenCredentialAuthenticationTests.cs @@ -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 act = async () => await serviceClient.SendAsync(ghostDevice, message).ConfigureAwait(false); + + // assert + await act.Should().ThrowAsync(); } #endif