private async Task ValidateEvent(string deviceId, string eventId, string payload, string p1Value,
                                         EventHubTestListener testListener, AzureSecurityCenterForIoTLogAnalyticsClient logAnalticsTestClient)
        {
            bool isReceivedEventHub = await testListener.WaitForMessage(deviceId, payload, p1Value).ConfigureAwait(false);

            Assert.IsFalse(isReceivedEventHub, "Security message received in customer event hub.");
            bool isReceivedOms = await logAnalticsTestClient.IsRawEventExist(deviceId, eventId).ConfigureAwait(false);

            Assert.IsTrue(isReceivedOms, "Security message was not recived in customer log analytics");
        }
 private async Task ValidateEventAsync(
     string deviceId,
     string eventId,
     string payload,
     string p1Value,
     AzureSecurityCenterForIoTLogAnalyticsClient logAnalticsTestClient)
 {
     bool isReceivedEventHub = EventHubTestListener.VerifyIfMessageIsReceived(deviceId, payload, p1Value, TimeSpan.FromSeconds(10));
     Assert.IsFalse(isReceivedEventHub, "Security message received in customer event hub.");
     bool isReceivedOms = await logAnalticsTestClient.IsRawEventExist(deviceId, eventId).ConfigureAwait(false);
     Assert.IsTrue(isReceivedOms, "Security message was not received in customer log analytics");
 }
        private async Task SendSingleSecurityMessageModuleAsync(
            ModuleClient moduleClient,
            string deviceId,
            AzureSecurityCenterForIoTLogAnalyticsClient logAnalticsTestClient)
        {
            await moduleClient.OpenAsync().ConfigureAwait(false);

            Client.Message testMessage = ComposeD2CSecurityTestMessage(out string eventId, out string payload, out string p1Value);
            await moduleClient.SendEventAsync(testMessage).ConfigureAwait(false);

            await ValidateEventAsync(deviceId, eventId, payload, p1Value, logAnalticsTestClient).ConfigureAwait(false);
        }
コード例 #4
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_logAnalyticsClient != null)
                {
                    _logAnalyticsClient.Dispose();
                    _logAnalyticsClient = null;
                }

                if (_listener != null)
                {
                    _listener.Dispose();
                    _listener = null;
                }
            }
        }
 public AzureSecurityCenterForIoTSecurityMessageE2ETests()
 {
     _listener = TestConfig.StartEventListener();
     _logAnalyticsClient = AzureSecurityCenterForIoTLogAnalyticsClient.CreateClient();
 }
        private Task SendSingleSecurityMessageModule(ModuleClient moduleClient, string deviceId, EventHubTestListener testListener, AzureSecurityCenterForIoTLogAnalyticsClient logAnalticsTestClient)
        {
            moduleClient.OpenAsync();

            Client.Message testMessage = ComposeD2CSecurityTestMessage(out string eventId, out string payload, out string p1Value);
            moduleClient.SendEventAsync(testMessage);

            return(ValidateEvent(deviceId, eventId, payload, p1Value, testListener, logAnalticsTestClient));
        }