Skip to content

Commit

Permalink
Update to openapi 2.9.2 (#522)
Browse files Browse the repository at this point in the history
* Update spec to 2.9.2
* Add ITs for brand scenarios.
* Fix StyleCop warnings.
* Add OIE policies ITs.
* Implement UpdateOrgLogo
* Add tests for org.UpdateOrgLogo
* Add support for MultipartFormDataPayloadHandler
* Fix tests.
* Remove ListFactorsForNewUsers tests since doesn't longer make sense with oie.
  • Loading branch information
laura-rodriguez authored Nov 19, 2021
1 parent 1ea6de9 commit 55bb6cf
Show file tree
Hide file tree
Showing 143 changed files with 3,569 additions and 100 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@
Running changelog of releases since `3.1.1`


## v5.2.2
## v5.3.0

### Features

- Add ability to use pre-requested access tokens for authentication. #508
- Add ability to use pre-requested access tokens for authentication (#508)
- Regenerate code using the [open API spec v2.9.2](https://github.com/okta/okta-management-openapi-spec/releases/tag/openapi-2.9.2)
- Add new models and operations to support [Brands API's endpoints](https://developer.okta.com/docs/reference/api/brands/)
- Add new models and operations to support [OIE policies](https://developer.okta.com/docs/reference/api/policy/)

### Updates

- `Group.AssignRoleAsync(IAssignRoleRequest assignRoleRequest, string disableNotifications, CancellationToken cancellationToken = default(CancellationToken));` is not marked as obsolete. Use `Group.AssignRoleAsync(IAssignRoleRequest assignRoleRequest, bool? disableNotifications = null, CancellationToken cancellationToken = default(CancellationToken));` instead.
- `UsersClient. AssignRoleToUserAsync(IAssignRoleRequest assignRoleRequest, string userId, string disableNotifications, CancellationToken cancellationToken = default(CancellationToken));` is not marked as obsolete. Use `UsersClient. AssignRoleToUserAsync(IAssignRoleRequest assignRoleRequest, string userId, bool? disableNotifications = null, CancellationToken cancellationToken = default(CancellationToken));` instead.


## v5.2.1
Expand Down
9 changes: 9 additions & 0 deletions openapi/errata.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ const modelErrata = [
{ path: 'CSRMetadataSubjectAltNames', rename: 'CsrMetadataSubjectAltNames', renameReason: 'Pattern consistency' },
{ path: 'UserSchema', includeNullValues: true },
{ path: 'GroupSchema', includeNullValues: true },
{ path: 'AuthenticatorProviderConfigurationUserNamePlate', rename: 'AuthenticatorProviderConfigurationUserNameTemplate', renameReason: 'Fix typo' },
];

const operationErrata = [
Expand Down Expand Up @@ -316,6 +317,10 @@ const modelMethodSkipList = [
{ path: 'User.listGroups', reason: 'Implemented as IUser.Groups' },
{ path: 'User.resetPassword', reason: 'Simplified as IUser.ResetPasswordAsync(bool)' },
{ path: 'Group.listUsers', reason: 'Implemented as IGroup.Users' },
{ path: 'Theme.updateBrandThemeBackgroundImage', reason: 'Implemented manually' },
{ path: 'Theme.updateBrandThemeFavicon', reason: 'Implemented manually' },
{ path: 'Theme.uploadBrandThemeLogo', reason: 'Implemented manually' },
{ path: 'OrgSetting.updateOrgLogo', reason: 'Implemented manually' }
];

function shouldSkipModelMethod(fullPath) {
Expand All @@ -336,6 +341,10 @@ const operationSkipList = [
{ id: 'publishDerCert', reason: 'Operation defined manually' },
{ id: 'publishBinaryDerCert', reason: 'Operation defined manually' },
{ id: 'publishBinaryPemCert', reason: 'Operation defined manually' },
{ id: 'uploadBrandThemeBackgroundImage', reason: 'Operation defined manually'},
{ id: 'uploadBrandThemeFavicon', reason: 'Operation defined manually'},
{ id: 'uploadBrandThemeLogo', reason: 'Operation defined manually'},
{ id: 'updateOrgLogo', reason: 'Operation defined manually'}
];

function shouldSkipOperation(operationId) {
Expand Down
24 changes: 12 additions & 12 deletions openapi/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"homepage": "https://github.com/okta/oktasdk-sdk-dotnet#readme",
"devDependencies": {
"@okta/openapi": "^2.7.1",
"@okta/openapi": "^2.9.2",
"json-stable-stringify": "^1.0.1",
"lodash": "^4.17.21"
}
Expand Down
1 change: 0 additions & 1 deletion src/Okta.Sdk.IntegrationTests/ApplicationScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1858,6 +1858,5 @@ public async Task UpdateApplicationProfile()
await oktaClient.Applications.DeleteApplicationAsync(newApp.Id);
}
}

}
}
26 changes: 26 additions & 0 deletions src/Okta.Sdk.IntegrationTests/AuthenticatorScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,31 @@ public async Task GetAuthenticatorByIdAsync()
retrievedAuthenticator.Created.Should().Be(passwordAuthenticator.Created);
retrievedAuthenticator.Settings.Should().Be(passwordAuthenticator.Settings);
}

[Fact]
public async Task UpdateAuthenticatorsAsync()
{
var client = TestClient.Create();

var authenticator = await client.Authenticators.ListAuthenticators().FirstOrDefaultAsync();

var originalName = authenticator.Name;
var originalAllowedFor = authenticator.Settings.AllowedFor;

authenticator.Name = originalName + "-updated";
authenticator.Settings.AllowedFor = AllowedForEnum.Any;
try
{
var updatedAuthenticator = await client.Authenticators.UpdateAuthenticatorAsync(authenticator, authenticator.Id);
updatedAuthenticator.Name.Should().Be(authenticator.Name);
updatedAuthenticator.Settings.AllowedFor.Should().Be(AllowedForEnum.Any);
}
finally
{
authenticator.Name = originalName;
authenticator.Settings.AllowedFor = originalAllowedFor;
await client.Authenticators.UpdateAuthenticatorAsync(authenticator, authenticator.Id);
}
}
}
}
154 changes: 154 additions & 0 deletions src/Okta.Sdk.IntegrationTests/BrandScenarios.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
// <copyright file="BrandScenarios.cs" company="Okta, Inc">
// Copyright (c) 2020 - present Okta, Inc. All rights reserved.
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information.
// </copyright>

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using FluentAssertions;
using FluentAssertions.Extensions;
using Xunit;

namespace Okta.Sdk.IntegrationTests
{
public class BrandScenarios
{
[Fact]
public async Task UpdateBrand()
{
var client = TestClient.Create();

var brand = await client.Brands.ListBrands().FirstOrDefaultAsync();
var originalCustomPrivacyPolicyUrl = brand.CustomPrivacyPolicyUrl;

brand.CustomPrivacyPolicyUrl = "https://www.someHost.com/privacy-policy";
brand.AgreeToCustomPrivacyPolicy = true;

try
{
var updatedBrand = await client.Brands.UpdateBrandAsync(brand, brand.Id);
updatedBrand.Id.Should().Be(brand.Id);
updatedBrand.CustomPrivacyPolicyUrl.Should().Be(brand.CustomPrivacyPolicyUrl);
}
finally
{
brand.CustomPrivacyPolicyUrl = originalCustomPrivacyPolicyUrl;
await client.Brands.UpdateBrandAsync(brand, brand.Id);
}
}

[Fact]
public async Task ListBrands()
{
var client = TestClient.Create();

var brands = await client.Brands.ListBrands().ToListAsync();

brands.Should().NotBeNullOrEmpty();
brands.First().Id.Should().NotBeNullOrEmpty();
}

[Fact]
public async Task GetBrand()
{
var client = TestClient.Create();

var brand = await client.Brands.ListBrands().FirstOrDefaultAsync();

var retrievedBrand = await client.Brands.GetBrandAsync(brand.Id);

retrievedBrand.Id.Should().Be(brand.Id);
retrievedBrand.CustomPrivacyPolicyUrl.Should().Be(brand.CustomPrivacyPolicyUrl);
retrievedBrand.RemovePoweredByOkta.Should().Be(brand.RemovePoweredByOkta);
}

[Fact]
public async Task GetBrandThemes()
{
var client = TestClient.Create();

var brand = await client.Brands.ListBrands().FirstOrDefaultAsync();

var themes = await client.Brands.ListBrandThemes(brand.Id).ToListAsync();
themes.Should().NotBeNullOrEmpty();
themes.First().Id.Should().NotBeNullOrEmpty();
}

[Fact]
public async Task GetBrandTheme()
{
var client = TestClient.Create();

var brand = await client.Brands.ListBrands().FirstOrDefaultAsync();

var theme = await client.Brands.ListBrandThemes(brand.Id).FirstOrDefaultAsync();

var retrievedTheme = await client.Brands.GetBrandThemeAsync(brand.Id, theme.Id);
retrievedTheme.Id.Should().Be(theme.Id);
retrievedTheme.BackgroundImage.Should().Be(theme.BackgroundImage);
retrievedTheme.EmailTemplateTouchPointVariant.Should().Be(theme.EmailTemplateTouchPointVariant);
retrievedTheme.EndUserDashboardTouchPointVariant.Should().Be(theme.EndUserDashboardTouchPointVariant);
retrievedTheme.ErrorPageTouchPointVariant.Should().Be(theme.ErrorPageTouchPointVariant);
retrievedTheme.Favicon.Should().Be(theme.Favicon);
retrievedTheme.Logo.Should().Be(theme.Logo);
retrievedTheme.PrimaryColorContrastHex.Should().Be(theme.PrimaryColorContrastHex);
retrievedTheme.PrimaryColorHex.Should().Be(theme.PrimaryColorHex);
retrievedTheme.SecondaryColorContrastHex.Should().Be(theme.SecondaryColorContrastHex);
retrievedTheme.SecondaryColorHex.Should().Be(theme.SecondaryColorHex);
retrievedTheme.SignInPageTouchPointVariant.Should().Be(theme.SignInPageTouchPointVariant);
}

[Fact]
public async Task UpdateBrandTheme()
{
var client = TestClient.Create();

var brand = await client.Brands.ListBrands().FirstOrDefaultAsync();

var theme = await client.Brands.ListBrandThemes(brand.Id).FirstOrDefaultAsync();

var originalPrimaryColorHex = theme.PrimaryColorHex;
var originalSecondaryColorHex = theme.SecondaryColorHex;
var originalSignInPageTouchPointVariant = theme.SignInPageTouchPointVariant;
var originalEndUserDashboardTouchPointVariant = theme.EndUserDashboardTouchPointVariant;
var originalErrorPageTouchPointVariant = theme.ErrorPageTouchPointVariant;
var originalEmailTemplateTouchPointVariant = theme.EmailTemplateTouchPointVariant;

var themeToUpdate = new Theme
{
PrimaryColorHex = "#1662dd",
SecondaryColorHex = "#ebebed",
SignInPageTouchPointVariant = SignInPageTouchPointVariant.OktaDefault,
EndUserDashboardTouchPointVariant = EndUserDashboardTouchPointVariant.OktaDefault,
ErrorPageTouchPointVariant = ErrorPageTouchPointVariant.OktaDefault,
EmailTemplateTouchPointVariant = EmailTemplateTouchPointVariant.OktaDefault,
};

try
{
var updatedTheme = await client.Brands.UpdateBrandThemeAsync(themeToUpdate, brand.Id, theme.Id);

updatedTheme.Id.Should().Be(theme.Id);
updatedTheme.PrimaryColorHex.Should().Be(themeToUpdate.PrimaryColorHex);
updatedTheme.SecondaryColorHex.Should().Be(themeToUpdate.SecondaryColorHex);
updatedTheme.SignInPageTouchPointVariant.Should().Be(themeToUpdate.SignInPageTouchPointVariant);
updatedTheme.EndUserDashboardTouchPointVariant.Should().Be(themeToUpdate.EndUserDashboardTouchPointVariant);
updatedTheme.ErrorPageTouchPointVariant.Should().Be(themeToUpdate.ErrorPageTouchPointVariant);
updatedTheme.EmailTemplateTouchPointVariant.Should().Be(themeToUpdate.EmailTemplateTouchPointVariant);
}
finally
{
themeToUpdate.PrimaryColorHex = originalPrimaryColorHex;
themeToUpdate.SecondaryColorHex = originalSecondaryColorHex;
themeToUpdate.SignInPageTouchPointVariant = originalSignInPageTouchPointVariant;
themeToUpdate.EndUserDashboardTouchPointVariant = originalEndUserDashboardTouchPointVariant;
themeToUpdate.ErrorPageTouchPointVariant = originalErrorPageTouchPointVariant;
themeToUpdate.EmailTemplateTouchPointVariant = originalEmailTemplateTouchPointVariant;
await client.Brands.UpdateBrandThemeAsync(themeToUpdate, brand.Id, theme.Id);
}
}
}
}
46 changes: 6 additions & 40 deletions src/Okta.Sdk.IntegrationTests/FactorScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public async Task EnrollSecurityQuestionFactor()

try
{
await createdUser.AddFactorAsync(new AddSecurityQuestionFactorOptions
var createdUserFactor = await createdUser.AddFactorAsync(new AddSecurityQuestionFactorOptions
{
Question = "disliked_food",
Answer = "mayonnaise",
});

var factors = await createdUser.ListFactors().ToArrayAsync();
factors.Count().Should().Be(1);
factors.Any(x => x.Id == createdUserFactor.Id).Should().BeTrue();

var securityQuestionFactor = await createdUser.ListFactors().OfType<ISecurityQuestionUserFactor>().FirstOrDefaultAsync();
securityQuestionFactor.Should().NotBeNull();
Expand Down Expand Up @@ -81,14 +81,13 @@ public async Task EnrollSmsFactor()

try
{
await createdUser.AddFactorAsync(new AddSmsFactorOptions()
var createdUserFactor = await createdUser.AddFactorAsync(new AddSmsFactorOptions()
{
PhoneNumber = "+16284001133‬",
});

var factors = await createdUser.ListFactors().ToArrayAsync();
factors.Count().Should().Be(1);

factors.Any(x => x.Id == createdUserFactor.Id).Should().BeTrue();
var smsFactor = await createdUser.ListFactors().OfType<ISmsUserFactor>().FirstOrDefaultAsync();
smsFactor.Should().NotBeNull();
smsFactor.FactorType.Should().Be(FactorType.Sms);
Expand All @@ -100,39 +99,6 @@ await createdUser.AddFactorAsync(new AddSmsFactorOptions()
}
}

[Fact]
public async Task ListFactorsForNewUser()
{
var client = TestClient.Create();
var guid = Guid.NewGuid();

var profile = new UserProfile
{
FirstName = "Jack",
LastName = "List-Factors",
Email = $"jack-list-factors-dotnet-sdk-{guid}@example.com",
Login = $"jack-list-factors-dotnet-sdk-{guid}@example.com",
};
profile["nickName"] = "jack-list-users";

var createdUser = await client.Users.CreateUserAsync(new CreateUserWithPasswordOptions
{
Profile = profile,
Password = "Abcd1234",
});

try
{
var factors = await createdUser.Factors.ToArrayAsync();
factors.Count().Should().Be(0);
}
finally
{
await createdUser.DeactivateAsync();
await createdUser.DeactivateOrDeleteAsync();
}
}

[Fact]
public async Task GetFactor()
{
Expand Down Expand Up @@ -211,7 +177,7 @@ public async Task DeleteFactor()
await createdUser.DeleteFactorAsync(retrievedUserFactor.Id);

var factors = await createdUser.ListFactors().ToArrayAsync();
factors.Count().Should().Be(0);
factors.Any(x => x.Id == createdUserFactor.Id).Should().BeFalse();
}
finally
{
Expand Down Expand Up @@ -256,7 +222,7 @@ public async Task ResetFactors()
await createdUser.ResetFactorsAsync();

var factors = await createdUser.ListFactors().ToArrayAsync();
factors.Count().Should().Be(0);
factors.Any(x => x.Id == createdUserFactor.Id).Should().BeFalse();
}
finally
{
Expand Down
Loading

0 comments on commit 55bb6cf

Please sign in to comment.