Skip to content

Commit

Permalink
Merge pull request #2059 from Azure/abmisr/masterToPreviewPnp
Browse files Browse the repository at this point in the history
Bring updates from master to previews/pnpApi
  • Loading branch information
abhipsaMisra authored Jul 1, 2021
2 parents be43890 + 72b470b commit 50c1d23
Show file tree
Hide file tree
Showing 73 changed files with 693 additions and 510 deletions.
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Please follow the instructions and template below to save us time requesting add

Below is a generic bug report format. We recommend you use it as a template and replace the information below each header with your own.

Note that bugs that only affect unsupported platforms will likely be treated as feature requests, and may be closed as "won't fix" if we have no plans to support that platform. See [this document](../../supported_platforms.md) for details on which platforms are officially supported.

------------------------------- delete above -------------------------------


Expand Down
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Thank you for raising a feature request! To get started, here's a few things to

As an open source project, we welcome PRs for new features, and we don't want to reject any hard work you've done to contribute. **So propose your solution through an issue first** so we can discuss the changes, and if things look good we will ask you submit a PR to implement the changes.

Note that feature requests that only affect unsupported platforms may be closed as "won't fix" if we have no plans to support that platform. See [this document](../../supported_platforms.md) for details on which platforms are officially supported.

------------------------------- delete above -------------------------------

**Is your feature request related to a problem? Please describe.**
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/github_issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
- uses: danhellem/github-actions-issue-to-work-item@master
env:
ado_token: "${{ secrets.ADO_PERSONAL_ACCESS_TOKEN }}"
github_token: "${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}"
ado_organization: "${{ secrets.ADO_ORGANIZATION }}"
ado_project: "${{ secrets.ADO_PROJECT }}"
ado_area_path: "${{ secrets.ADO_AREA_PATH }}"
Expand Down
2 changes: 2 additions & 0 deletions common/src/service/CommonConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ internal static class CommonConstants

public const string HttpErrorCodeName = "iothub-errorcode";

public static readonly string[] IotHubAadTokenScopes = new string[] { "https://iothubs.azure.net/.default" };

//Service Analytics related
public static class ServiceAnalytics
{
Expand Down
2 changes: 1 addition & 1 deletion e2e/test/Helpers/StorageContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected virtual void Dispose(bool disposing)

private async Task InitializeAsync()
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Configuration.Storage.ConnectionString);
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(TestConfiguration.Storage.ConnectionString);
CloudBlobClient cloudBlobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer = cloudBlobClient.GetContainerReference(ContainerName);
await CloudBlobContainer.CreateIfNotExistsAsync().ConfigureAwait(false);
Expand Down
14 changes: 7 additions & 7 deletions e2e/test/Helpers/TestDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static async Task<TestDevice> CreateDeviceAsync(TestDeviceType type, str
string deviceName = "E2E_" + prefix + Guid.NewGuid();

// Delete existing devices named this way and create a new one.
using var rm = RegistryManager.CreateFromConnectionString(Configuration.IoTHub.ConnectionString);
using var rm = RegistryManager.CreateFromConnectionString(TestConfiguration.IoTHub.ConnectionString);
s_logger.Trace($"{nameof(GetTestDeviceAsync)}: Creating device {deviceName} with type {type}.");

Client.IAuthenticationMethod auth = null;
Expand All @@ -84,11 +84,11 @@ private static async Task<TestDevice> CreateDeviceAsync(TestDeviceType type, str
{
X509Thumbprint = new X509Thumbprint
{
PrimaryThumbprint = Configuration.IoTHub.GetCertificateWithPrivateKey().Thumbprint
PrimaryThumbprint = TestConfiguration.IoTHub.GetCertificateWithPrivateKey().Thumbprint
}
};

auth = new DeviceAuthenticationWithX509Certificate(deviceName, Configuration.IoTHub.GetCertificateWithPrivateKey());
auth = new DeviceAuthenticationWithX509Certificate(deviceName, TestConfiguration.IoTHub.GetCertificateWithPrivateKey());
}

Device device = null;
Expand Down Expand Up @@ -118,15 +118,15 @@ public string ConnectionString
{
get
{
string iotHubHostName = GetHostName(Configuration.IoTHub.ConnectionString);
string iotHubHostName = GetHostName(TestConfiguration.IoTHub.ConnectionString);
return $"HostName={iotHubHostName};DeviceId={Device.Id};SharedAccessKey={Device.Authentication.SymmetricKey.PrimaryKey}";
}
}

/// <summary>
/// Used in conjunction with DeviceClient.Create()
/// </summary>
public string IoTHubHostName => GetHostName(Configuration.IoTHub.ConnectionString);
public string IoTHubHostName => GetHostName(TestConfiguration.IoTHub.ConnectionString);

/// <summary>
/// Device Id
Expand Down Expand Up @@ -171,7 +171,7 @@ public DeviceClient CreateDeviceClient(ITransportSettings[] transportSettings, C
}
else
{
deviceClient = DeviceClient.CreateFromConnectionString(Configuration.IoTHub.ConnectionString, Device.Id, transportSettings, options);
deviceClient = DeviceClient.CreateFromConnectionString(TestConfiguration.IoTHub.ConnectionString, Device.Id, transportSettings, options);
s_logger.Trace($"{nameof(CreateDeviceClient)}: Created {nameof(DeviceClient)} {Device.Id} from IoTHub connection string: ID={TestLogger.IdOf(deviceClient)}");
}
}
Expand All @@ -186,7 +186,7 @@ public DeviceClient CreateDeviceClient(ITransportSettings[] transportSettings, C

public async Task RemoveDeviceAsync()
{
using var rm = RegistryManager.CreateFromConnectionString(Configuration.IoTHub.ConnectionString);
using var rm = RegistryManager.CreateFromConnectionString(TestConfiguration.IoTHub.ConnectionString);
await rm.RemoveDeviceAsync(Id).ConfigureAwait(false);
}
}
Expand Down
4 changes: 2 additions & 2 deletions e2e/test/Helpers/TestModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static async Task<TestModule> GetTestModuleAsync(string deviceNamePrefix,
string deviceName = testDevice.Id;
string moduleName = "E2E_" + moduleNamePrefix + Guid.NewGuid();

using var rm = RegistryManager.CreateFromConnectionString(Configuration.IoTHub.ConnectionString);
using var rm = RegistryManager.CreateFromConnectionString(TestConfiguration.IoTHub.ConnectionString);
logger.Trace($"{nameof(GetTestModuleAsync)}: Creating module for device {deviceName}.");

var requestModule = new Module(deviceName, moduleName);
Expand All @@ -49,7 +49,7 @@ public string ConnectionString
{
get
{
string iotHubHostName = GetHostName(Configuration.IoTHub.ConnectionString);
string iotHubHostName = GetHostName(TestConfiguration.IoTHub.ConnectionString);
return $"HostName={iotHubHostName};DeviceId={_module.DeviceId};ModuleId={_module.Id};SharedAccessKey={_module.Authentication.SymmetricKey.PrimaryKey}";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.Azure.Devices.E2ETests
{
public static partial class Configuration
public static partial class TestConfiguration
{
public static class AzureSecurityCenterForIoTLogAnalytics
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace Microsoft.Azure.Devices.E2ETests
{
public static partial class Configuration
public static partial class TestConfiguration
{
public static partial class IoTHub
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Microsoft.Azure.Devices.E2ETests
{
public static partial class Configuration
public static partial class TestConfiguration
{
public static partial class Provisioning
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Microsoft.Azure.Devices.E2ETests
{
public static partial class Configuration
public static partial class TestConfiguration
{
public static class Storage
{
Expand All @@ -17,7 +17,7 @@ public static class Storage

static Storage()
{
ConnectionString = Configuration.GetValue("STORAGE_ACCOUNT_CONNECTION_STRING");
ConnectionString = TestConfiguration.GetValue("STORAGE_ACCOUNT_CONNECTION_STRING");
Name = s_saName.Match(ConnectionString).Value;
Key = s_saKey.Match(ConnectionString).Value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Microsoft.Azure.Devices.E2ETests
{
public static partial class Configuration
public static partial class TestConfiguration
{
private static string GetValue(string envName, string defaultValue = null)
{
Expand Down
2 changes: 1 addition & 1 deletion e2e/test/iothub/CombinedClientOperationsPoolAmqpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private async Task DeviceCombinedClientOperationsAsync(
ConnectionStringAuthScope authScope = ConnectionStringAuthScope.Device)
{
// Initialize service client for service-side operations
using var serviceClient = ServiceClient.CreateFromConnectionString(Configuration.IoTHub.ConnectionString);
using var serviceClient = ServiceClient.CreateFromConnectionString(TestConfiguration.IoTHub.ConnectionString);

// Message payload and properties for C2D operation
var messagesSent = new Dictionary<string, Tuple<Message, string>>();
Expand Down
6 changes: 3 additions & 3 deletions e2e/test/iothub/ConnectionStatusChangeHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private async Task DeviceClient_Gives_ConnectionStatus_DeviceDisabled_Base(
TestDevice testDevice = await TestDevice.GetTestDeviceAsync(Logger, DevicePrefix + $"_{Guid.NewGuid()}").ConfigureAwait(false);
string deviceConnectionString = testDevice.ConnectionString;

var config = new Configuration.IoTHub.ConnectionStringParser(deviceConnectionString);
var config = new TestConfiguration.IoTHub.ConnectionStringParser(deviceConnectionString);
string deviceId = config.DeviceID;

ConnectionStatus? status = null;
Expand Down Expand Up @@ -139,7 +139,7 @@ private async Task DeviceClient_Gives_ConnectionStatus_DeviceDisabled_Base(
Assert.IsNotNull(twin);

// Delete/disable the device in IoT Hub. This should trigger the ConnectionStatusChangesHandler.
using (RegistryManager registryManager = RegistryManager.CreateFromConnectionString(Configuration.IoTHub.ConnectionString))
using (RegistryManager registryManager = RegistryManager.CreateFromConnectionString(TestConfiguration.IoTHub.ConnectionString))
{
await registryManagerOperation(registryManager, deviceId).ConfigureAwait(false);
}
Expand Down Expand Up @@ -198,7 +198,7 @@ private async Task ModuleClient_Gives_ConnectionStatus_DeviceDisabled_Base(
Assert.IsNotNull(twin);

// Delete/disable the device in IoT Hub.
using (RegistryManager registryManager = RegistryManager.CreateFromConnectionString(Configuration.IoTHub.ConnectionString))
using (RegistryManager registryManager = RegistryManager.CreateFromConnectionString(TestConfiguration.IoTHub.ConnectionString))
{
await registryManagerOperation(registryManager, testModule.DeviceId).ConfigureAwait(false);
}
Expand Down
24 changes: 12 additions & 12 deletions e2e/test/iothub/DeviceClientX509AuthenticationE2ETests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class DeviceClientX509AuthenticationE2ETests : E2EMsTestBase

public DeviceClientX509AuthenticationE2ETests()
{
_hostName = GetHostName(Configuration.IoTHub.ConnectionString);
_hostName = GetHostName(TestConfiguration.IoTHub.ConnectionString);
}

[LoggedTestMethod]
Expand Down Expand Up @@ -148,12 +148,12 @@ public async Task X509_Cert_Chain_Install_Test_MQTT_TCP()
{
// arrange
var chainCerts = new X509Certificate2Collection();
chainCerts.Add(Configuration.IoTHub.GetRootCACertificate());
chainCerts.Add(Configuration.IoTHub.GetIntermediate1Certificate());
chainCerts.Add(Configuration.IoTHub.GetIntermediate2Certificate());
chainCerts.Add(TestConfiguration.IoTHub.GetRootCACertificate());
chainCerts.Add(TestConfiguration.IoTHub.GetIntermediate1Certificate());
chainCerts.Add(TestConfiguration.IoTHub.GetIntermediate2Certificate());
var auth = new DeviceAuthenticationWithX509Certificate(
Configuration.IoTHub.X509ChainDeviceName,
Configuration.IoTHub.GetChainDeviceCertificateWithPrivateKey(),
TestConfiguration.IoTHub.X509ChainDeviceName,
TestConfiguration.IoTHub.GetChainDeviceCertificateWithPrivateKey(),
chainCerts);
using var deviceClient = DeviceClient.Create(
_hostName,
Expand All @@ -173,12 +173,12 @@ public async Task X509_Cert_Chain_Install_Test_AMQP_TCP()
{
// arrange
var chainCerts = new X509Certificate2Collection();
chainCerts.Add(Configuration.IoTHub.GetRootCACertificate());
chainCerts.Add(Configuration.IoTHub.GetIntermediate1Certificate());
chainCerts.Add(Configuration.IoTHub.GetIntermediate2Certificate());
chainCerts.Add(TestConfiguration.IoTHub.GetRootCACertificate());
chainCerts.Add(TestConfiguration.IoTHub.GetIntermediate1Certificate());
chainCerts.Add(TestConfiguration.IoTHub.GetIntermediate2Certificate());
var auth = new DeviceAuthenticationWithX509Certificate(
Configuration.IoTHub.X509ChainDeviceName,
Configuration.IoTHub.GetChainDeviceCertificateWithPrivateKey(),
TestConfiguration.IoTHub.X509ChainDeviceName,
TestConfiguration.IoTHub.GetChainDeviceCertificateWithPrivateKey(),
chainCerts);
using var deviceClient = DeviceClient.Create(
_hostName,
Expand Down Expand Up @@ -293,7 +293,7 @@ private async Task X509InvalidDeviceIdOpenAsyncTwiceTest(Client.TransportType tr
private DeviceClient CreateDeviceClientWithInvalidId(Client.TransportType transportType)
{
string deviceName = $"DEVICE_NOT_EXIST_{Guid.NewGuid()}";
var auth = new DeviceAuthenticationWithX509Certificate(deviceName, Configuration.IoTHub.GetCertificateWithPrivateKey());
var auth = new DeviceAuthenticationWithX509Certificate(deviceName, TestConfiguration.IoTHub.GetCertificateWithPrivateKey());
return DeviceClient.Create(_hostName, auth, transportType);
}
}
Expand Down
6 changes: 3 additions & 3 deletions e2e/test/iothub/DeviceTokenRefreshE2ETests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task DeviceClient_Not_Exist_AMQP()
{
TestDevice testDevice = await TestDevice.GetTestDeviceAsync(Logger, DevicePrefix).ConfigureAwait(false);

var config = new Configuration.IoTHub.ConnectionStringParser(testDevice.ConnectionString);
var config = new TestConfiguration.IoTHub.ConnectionStringParser(testDevice.ConnectionString);
using (DeviceClient deviceClient = DeviceClient.CreateFromConnectionString($"HostName={config.IotHubHostName};DeviceId=device_id_not_exist;SharedAccessKey={config.SharedAccessKey}", Client.TransportType.Amqp_Tcp_Only))
{
await deviceClient.OpenAsync().ConfigureAwait(false);
Expand All @@ -43,7 +43,7 @@ public async Task DeviceClient_Bad_Credentials_AMQP()
{
TestDevice testDevice = await TestDevice.GetTestDeviceAsync(Logger, DevicePrefix).ConfigureAwait(false);

var config = new Configuration.IoTHub.ConnectionStringParser(testDevice.ConnectionString);
var config = new TestConfiguration.IoTHub.ConnectionStringParser(testDevice.ConnectionString);
string invalidKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("invalid_key"));
using (DeviceClient deviceClient = DeviceClient.CreateFromConnectionString($"HostName={config.IotHubHostName};DeviceId={config.DeviceID};SharedAccessKey={invalidKey}", Client.TransportType.Amqp_Tcp_Only))
{
Expand Down Expand Up @@ -82,7 +82,7 @@ public async Task DeviceClient_TokenConnectionDoubleRelease_Ok()

string deviceConnectionString = testDevice.ConnectionString;

var config = new Configuration.IoTHub.ConnectionStringParser(deviceConnectionString);
var config = new TestConfiguration.IoTHub.ConnectionStringParser(deviceConnectionString);
string iotHub = config.IotHubHostName;
string deviceId = config.DeviceID;
string key = config.SharedAccessKey;
Expand Down
2 changes: 1 addition & 1 deletion e2e/test/iothub/FaultInjectionPoolAmqpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ namespace Microsoft.Azure.Devices.E2ETests
[TestCategory("LongRunning")]
public partial class FaultInjectionPoolAmqpTests : E2EMsTestBase
{
private static readonly string s_proxyServerAddress = Configuration.IoTHub.ProxyServerAddress;
private static readonly string s_proxyServerAddress = TestConfiguration.IoTHub.ProxyServerAddress;
}
}
11 changes: 5 additions & 6 deletions e2e/test/iothub/FileUploadE2ETests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public async Task FileUpload_SmallFile_Http_GranularSteps_Proxy()
using var fileStreamSource = new FileStream(filename, FileMode.Open, FileAccess.Read);
var fileUploadTransportSettings = new Http1TransportSettings()
{
Proxy = new WebProxy(Configuration.IoTHub.ProxyServerAddress)
Proxy = new WebProxy(TestConfiguration.IoTHub.ProxyServerAddress)
};

await UploadFileGranularAsync(fileStreamSource, filename, fileUploadTransportSettings).ConfigureAwait(false);
Expand All @@ -124,11 +124,10 @@ private async Task UploadFileGranularAsync(Stream source, string filename, Http1

if (x509auth)
{
X509Certificate2 cert = Configuration.IoTHub.GetCertificateWithPrivateKey();
X509Certificate2 cert = TestConfiguration.IoTHub.GetCertificateWithPrivateKey();

var auth = new DeviceAuthenticationWithX509Certificate(testDevice.Id, cert);

deviceClient = DeviceClient.Create(testDevice.IoTHubHostName, auth, Client.TransportType.Http1, clientOptions);
deviceClient = DeviceClient.Create(testDevice.IoTHubHostName, auth, Client.TransportType.Http1);
}
else
{
Expand Down Expand Up @@ -166,7 +165,7 @@ private async Task UploadFileAsync(Client.TransportType transport, string filena
DeviceClient deviceClient;
if (x509auth)
{
X509Certificate2 cert = Configuration.IoTHub.GetCertificateWithPrivateKey();
X509Certificate2 cert = TestConfiguration.IoTHub.GetCertificateWithPrivateKey();

var auth = new DeviceAuthenticationWithX509Certificate(testDevice.Id, cert);
deviceClient = DeviceClient.Create(testDevice.IoTHubHostName, auth, transport);
Expand Down Expand Up @@ -198,7 +197,7 @@ private async Task GetSasUriAsync(Client.TransportType transport, string blobNam
DeviceClient deviceClient;
if (x509auth)
{
X509Certificate2 cert = Configuration.IoTHub.GetCertificateWithPrivateKey();
X509Certificate2 cert = TestConfiguration.IoTHub.GetCertificateWithPrivateKey();

var auth = new DeviceAuthenticationWithX509Certificate(testDevice.Id, cert);
deviceClient = DeviceClient.Create(testDevice.IoTHubHostName, auth, transport);
Expand Down
Loading

0 comments on commit 50c1d23

Please sign in to comment.