public async Task update_azureAD_Application()
    {
        var appUri = string.Format("https://{0}/{1}", tenantId, "unittestmsiot");
        var repo   = new ServicePrincipalRepository(activeDirectoryClient, logger);
        var app    = await repo.CreateAppAndServicePrincipal("unittestmsiot",
                                                             appUri,
                                                             "msiot123",
                                                             tenantId);

        Assert.Equal("unittestmsiot", app.App.DisplayName);

        var updateModel = new UpdateApplicationRequest
        {
            Homepage  = "https://localhostunitest",
            ReplyUrls = new List <string>
            {
                "https://localhostunitest"
            }
        };
        await repo.UpdateAzureADApplication(app.App.ObjectId,
                                            updateModel,
                                            tenantId);

        app = await repo.CreateAppAndServicePrincipal("unittestmsiot",
                                                      appUri,
                                                      "msiot123",
                                                      tenantId);

        Assert.Equal(updateModel.Homepage, app.App.Homepage);
        Assert.True(app.App.ReplyUrls.Contains("https://localhostunitest"));
    }
    public async Task update_azureAD_Application_PasswordCreds()
    {
        var appUri = string.Format("https://{0}/{1}", tenantId, "unittestmsiot");
        var repo   = new ServicePrincipalRepository(activeDirectoryClient, logger);
        var app    = await repo.CreateAppAndServicePrincipal("unittestmsiot",
                                                             appUri,
                                                             "msiot123",
                                                             tenantId);

        Assert.Equal("unittestmsiot", app.App.DisplayName);

        var updateModel = new UpdateApplicationRequest
        {
            Homepage  = "https://localhostunitest",
            ReplyUrls = new List <string>
            {
                "https://localhostunitest"
            }
        };
        await repo.UpdateAzureADApplication(app.App.ObjectId,
                                            updateModel,
                                            tenantId);

        app = await repo.CreateAppAndServicePrincipal("unittestmsiot",
                                                      appUri,
                                                      "msiot123",
                                                      tenantId);

        Assert.Equal(updateModel.Homepage, app.App.Homepage);
        Assert.True(app.App.ReplyUrls.Contains("https://localhostunitest"));

        // now update the password credentials object
        UpdateApplicationPasswordCredentials updateAppPasswordCreds =
            new UpdateApplicationPasswordCredentials
        {
            StartDate = DateTime.UtcNow,
            EndDate   = DateTime.UtcNow.AddYears(1),
            Value     = CreateRandomClientSecretKey(),
            KeyId     = Guid.NewGuid()
        };
        var passwordList = new List <UpdateApplicationPasswordCredentials>();

        passwordList.Add(updateAppPasswordCreds);

        var updateAppPasswordReq = new UpdateApplicationPasswordCredsRequest
        {
            UpdateApplicationPasswordCreds = passwordList
        };

        await repo.UpdateAzureADApplicationPasswordCredentials(app.App.ObjectId,
                                                               updateAppPasswordReq,
                                                               tenantId);

        app = await repo.CreateAppAndServicePrincipal("unittestmsiot",
                                                      appUri,
                                                      "msiot123",
                                                      tenantId);


        Assert.Equal(updateAppPasswordCreds.StartDate,
                     app.App.PasswordCredentials[0]
                     .StartDate);
        Assert.Equal(updateAppPasswordCreds.EndDate,
                     app.App.PasswordCredentials[0]
                     .EndDate);
    }