public async Task GetOrgPreferencesAsync()
        {
            var client         = TestClient.Create();
            var orgPreferences = await client.Orgs.GetOrgPreferencesAsync();

            orgPreferences.Should().NotBeNull();
        }
        public async Task GetOktaCommunicationSettingsAsync()
        {
            var client = TestClient.Create();
            var orgCommunicationSettings = await client.Orgs.GetOktaCommunicationSettingsAsync();

            orgCommunicationSettings.Should().NotBeNull();
        }
Beispiel #3
0
        public async Task ListAuthorizationServerKeys()
        {
            var testClient = TestClient.Create();
            var testAuthorizationServerName = $"{SdkPrefix}:Test AuthZ Server ({TestClient.RandomString(4)})";

            var testAuthorizationServer = new AuthorizationServer
            {
                Name        = testAuthorizationServerName,
                Description = "Test Authorization Server",
                Audiences   = new string[] { "api://default" },
            };

            var createdAuthorizationServer = await testClient.AuthorizationServers.CreateAuthorizationServerAsync(testAuthorizationServer);

            try
            {
                var authorizationServerKeys = await createdAuthorizationServer.ListKeys().ToListAsync();

                authorizationServerKeys.Should().NotBeNull();
                authorizationServerKeys.Count.Should().BeGreaterThan(0);
            }
            finally
            {
                await createdAuthorizationServer.DeactivateAsync();

                await testClient.AuthorizationServers.DeleteAuthorizationServerAsync(createdAuthorizationServer.Id);
            }
        }
        public async Task ExpireUserPassword()
        {
            var client = TestClient.Create();
            var guid   = Guid.NewGuid();

            // Create a user
            var createdUser = await client.Users.CreateUserAsync(new CreateUserWithPasswordOptions
            {
                Profile = new UserProfile
                {
                    FirstName = "John",
                    LastName  = "Expire-Password",
                    Email     = $"john-expire-password-dotnet-sdk-{guid}@example.com",
                    Login     = $"john-expire-password-dotnet-sdk-{guid}@example.com",
                },
                Password = "******",
                Activate = true,
            });

            try
            {
                // Expire the user password
                var tempPassword = await createdUser.ExpirePasswordAsync(tempPassword : true);

                tempPassword.Password.Should().NotBeNullOrEmpty();
            }
            finally
            {
                // Remove the user
                await createdUser.DeactivateAsync();

                await createdUser.DeactivateOrDeleteAsync();
            }
        }
Beispiel #5
0
        public async Task ListGroups()
        {
            var client = TestClient.Create();
            var guid   = Guid.NewGuid();

            var createdGroup = await client.Groups.CreateGroupAsync(new CreateGroupOptions
            {
                Name = $"dotnet-sdk: List Test Group {guid}",
            });

            try
            {
                var groupList = await client.Groups.ListGroups().ToArray();

                groupList.SingleOrDefault(g => g.Id == createdGroup.Id).Should().NotBeNull();
            }
            finally
            {
                await createdGroup.DeleteAsync();
            }

            // Getting by ID should result in 404 error
            await Assert.ThrowsAsync <OktaApiException>(
                () => client.Groups.GetGroupAsync(createdGroup.Id));
        }
Beispiel #6
0
        public async Task GetLogs()
        {
            var client = TestClient.Create();

            // Create an Application so there is something in the logs
            var createdApp = await client.Applications.CreateApplicationAsync(new CreateBasicAuthApplicationOptions()
            {
                Label   = "App creation to be logged",
                Url     = "https://example.com/login.html",
                AuthUrl = "https://example.com/auth.html",
            });

            try
            {
                var logs = await client.Logs.GetLogs().ToList();

                logs.Should().NotBeNullOrEmpty();
            }
            finally
            {
                await client.Applications.DeactivateApplicationAsync(createdApp.Id);

                await client.Applications.DeleteApplicationAsync(createdApp.Id);
            }
        }
        public async Task CreateSmsTemplate()
        {
            var client       = TestClient.Create();
            var randomSuffix = DateTime.UtcNow.ToString();

            var smsTranslations = new SmsTemplateTranslations();

            smsTranslations.SetProperty("es", "${org.name}: el código de verificación es ${code}");
            smsTranslations.SetProperty("fr", "${org.name}: votre code de vérification est ${code}");

            var createdTemplate = await client.Templates.CreateSmsTemplateAsync(
                new SmsTemplate()
            {
                Name         = $"dotnet-sdk:Create{randomSuffix}",
                Type         = SmsTemplateType.SmsVerifyCode,
                Template     = "${org.name}: your verification code is ${code}",
                Translations = smsTranslations,
            });

            try
            {
                createdTemplate.Should().NotBeNull();
                createdTemplate.Name.Should().Be($"dotnet-sdk:Create{randomSuffix}");
                createdTemplate.Type.Should().Be(SmsTemplateType.SmsVerifyCode);
                createdTemplate.Template.Should().Be("${org.name}: your verification code is ${code}");
                createdTemplate.Translations.Should().NotBeNull();
                createdTemplate.Translations.GetProperty <string>("es").Should().Be("${org.name}: el código de verificación es ${code}");
                createdTemplate.Translations.GetProperty <string>("fr").Should().Be("${org.name}: votre code de vérification est ${code}");
            }
            finally
            {
                await client.Templates.DeleteSmsTemplateAsync(createdTemplate.Id);
            }
        }
        public async Task SearchGroups()
        {
            var client = TestClient.Create();

            var createdGroup = await client.Groups.CreateGroupAsync(new CreateGroupOptions
            {
                Name = "Search Test Group",
            });

            try
            {
                var groupList = await client.Groups
                                .ListGroups(createdGroup.Profile.GetProperty <string>("name"))
                                .ToArray();

                groupList.SingleOrDefault(g => g.Id == createdGroup.Id).Should().NotBeNull();
            }
            finally
            {
                await createdGroup.DeleteAsync();
            }

            // Getting by ID should result in 404 error
            await Assert.ThrowsAsync <OktaApiException>(
                () => client.Groups.GetGroupAsync(createdGroup.Id));
        }
        public async Task UpdateGroup()
        {
            var client = TestClient.Create();

            var createdGroup = await client.Groups.CreateGroupAsync(new CreateGroupOptions
            {
                Name = "Update Test Group",
            });

            await Task.Delay(1000);

            createdGroup.Profile.Description = "This group has been updated";

            try
            {
                var updatedGroup = await createdGroup.UpdateAsync();

                updatedGroup.LastUpdated.Value.Should().BeAfter(updatedGroup.Created.Value);
            }
            finally
            {
                await createdGroup.DeleteAsync();
            }

            // Getting by ID should result in 404 error
            await Assert.ThrowsAsync <OktaApiException>(
                () => client.Groups.GetGroupAsync(createdGroup.Id));
        }
Beispiel #10
0
        public async Task GetResetPasswordUrl()
        {
            var client = TestClient.Create();
            var guid   = Guid.NewGuid();

            var createdUser = await client.Users.CreateUserAsync(new CreateUserWithPasswordOptions
            {
                Profile = new UserProfile
                {
                    FirstName = "John",
                    LastName  = "Get-Reset-Password-URL",
                    Email     = $"john-get-reset-password-url-dotnet-sdk-{guid}@example.com",
                    Login     = $"john-get-reset-password-url-dotnet-sdk-{guid}@example.com",
                },
                Password = "******",
                Activate = true,
            });

            try
            {
                var resetPasswordToken = await createdUser.ResetPasswordAsync(sendEmail : false);

                resetPasswordToken.ResetPasswordUrl.Should().NotBeNullOrEmpty();
            }
            finally
            {
                // Deactivate + delete
                await createdUser.DeactivateAsync();

                await createdUser.DeactivateOrDeleteAsync();
            }
        }
Beispiel #11
0
        public async Task UpdateNetworkZone()
        {
            var         oktaClient         = TestClient.Create();
            var         zonesClient        = oktaClient.NetworkZones;
            NetworkZone newZone            = BuildNetworkZoneObject();
            var         createZoneResponse = await zonesClient.CreateNetworkZoneAsync(newZone);

            try
            {
                createZoneResponse.Name = "Another Name";
                createZoneResponse.Gateways.Add(new NetworkZoneAddress
                {
                    Type  = NetworkZoneAddressType.Cidr,
                    Value = "1.1.1.1/24",
                });

                var updateZoneResponse = await zonesClient.UpdateNetworkZoneAsync(createZoneResponse, createZoneResponse.Id);

                updateZoneResponse.Name.Should().Be(createZoneResponse.Name);
                updateZoneResponse.Gateways.Count.Should().Be(3);
            }
            finally
            {
                await zonesClient.DeleteNetworkZoneAsync(createZoneResponse.Id);
            }
        }
Beispiel #12
0
        [Trait("Category", "NoBacon")] // Tests that don't run on internal CI pipeline
        public async Task GetLogsByEventType()
        {
            var client = TestClient.Create();

            // Create an Application so there is something in the logs
            var createdApp = await client.Applications.CreateApplicationAsync(new CreateBasicAuthApplicationOptions()
            {
                Label   = $"dotnet-sdk: GetLogsByEventType {Guid.NewGuid()}",
                Url     = "https://example.com/login.html",
                AuthUrl = "https://example.com/auth.html",
            });

            try
            {
                var filter = "eventType eq \"directory.app_user_profile.bootstrap\"";
                var logs   = await client.Logs.GetLogs(null, null, filter).ToList();

                logs.Should().NotBeNullOrEmpty();
            }
            finally
            {
                await client.Applications.DeactivateApplicationAsync(createdApp.Id);

                await client.Applications.DeleteApplicationAsync(createdApp.Id);
            }
        }
        public async Task DeleteOrigin()
        {
            var client = TestClient.Create();
            var guid   = Guid.NewGuid();
            var testTrustedOriginName = $"{dotnetSdkPrefix}_{nameof(DeleteOrigin)}_{guid}_Test";
            var createdTrustedOrigin  = await client.TrustedOrigins.CreateOriginAsync(
                new TrustedOrigin
            {
                Name   = testTrustedOriginName,
                Origin = "http://example.com",
                Scopes = new List <IScope>()
                {
                    new Scope()
                    {
                        Type = ScopeType.Cors,
                    },
                    new Scope()
                    {
                        Type = ScopeType.Redirect,
                    },
                },
            });

            var retrievedTrustedOrigin = await client.TrustedOrigins.GetOriginAsync(createdTrustedOrigin.Id);

            retrievedTrustedOrigin.Should().NotBeNull();
            await client.TrustedOrigins.DeleteOriginAsync(createdTrustedOrigin.Id);

            var ex = await Assert.ThrowsAsync <OktaApiException>(() => client.TrustedOrigins.GetOriginAsync(createdTrustedOrigin.Id));

            ex.StatusCode.Should().Be(404);
        }
Beispiel #14
0
        public async Task ListCreatedAuthorizationServer()
        {
            var testClient = TestClient.Create();
            var testAuthorizationServerName = $"{SdkPrefix}:Test AuthZ Server ({TestClient.RandomString(4)})";
            var testAuthorizationServer     = new AuthorizationServer
            {
                Name        = testAuthorizationServerName,
                Description = "Test Authorization Server",
                Audiences   = new string[] { "api://default" },
            };

            var createdAuthorizationServer = await testClient.AuthorizationServers.CreateAuthorizationServerAsync(testAuthorizationServer);

            try
            {
                var authorizationServerIds = await testClient.AuthorizationServers.ListAuthorizationServers().Select(server => server.Id).ToHashSetAsync();

                authorizationServerIds.Should().Contain(createdAuthorizationServer.Id);
            }
            finally
            {
                await createdAuthorizationServer.DeactivateAsync();

                await testClient.AuthorizationServers.DeleteAuthorizationServerAsync(createdAuthorizationServer.Id);
            }
        }
Beispiel #15
0
        public async Task CreateOAuth2Scope()
        {
            var testClient = TestClient.Create();
            var testAuthorizationServerName = $"{SdkPrefix}:Test AuthZ Server ({TestClient.RandomString(4)})";

            var testAuthorizationServer = new AuthorizationServer
            {
                Name        = testAuthorizationServerName,
                Description = "Test Authorization Server",
                Audiences   = new string[] { "api://default" },
            };
            var testOAuthScope = new OAuth2Scope
            {
                Name = $"{SdkPrefix}:{nameof(CreateOAuth2Scope)}:TestOAuth2Scope({TestClient.RandomString(4)})",
            };

            var createdAuthorizationServer = await testClient.AuthorizationServers.CreateAuthorizationServerAsync(testAuthorizationServer);

            var createdOAuthScope = await createdAuthorizationServer.CreateOAuth2ScopeAsync(testOAuthScope);

            try
            {
                createdOAuthScope.Should().NotBeNull();
                createdOAuthScope.Name.Should().Be(testOAuthScope.Name);
            }
            finally
            {
                await createdAuthorizationServer.DeleteOAuth2ScopeAsync(createdOAuthScope.Id);

                await createdAuthorizationServer.DeactivateAsync();

                await testClient.AuthorizationServers.DeleteAuthorizationServerAsync(createdAuthorizationServer.Id);
            }
        }
Beispiel #16
0
        public async Task DeleteAuthorizationServer()
        {
            var testClient = TestClient.Create();
            var testAuthorizationServerName = $"{SdkPrefix}:Test AuthZ Server ({TestClient.RandomString(4)})";

            var testAuthorizationServer = new AuthorizationServer
            {
                Name        = testAuthorizationServerName,
                Description = "Test Authorization Server",
                Audiences   = new string[] { "api://default" },
            };

            var createdAuthorizationServer = await testClient.AuthorizationServers.CreateAuthorizationServerAsync(testAuthorizationServer);

            createdAuthorizationServer.Should().NotBeNull();
            var retrievedAuthorizationServer = await testClient.AuthorizationServers.GetAuthorizationServerAsync(createdAuthorizationServer.Id);

            retrievedAuthorizationServer.Should().NotBeNull();

            await createdAuthorizationServer.DeactivateAsync();

            await testClient.AuthorizationServers.DeleteAuthorizationServerAsync(createdAuthorizationServer.Id);

            var ex = await Assert.ThrowsAsync <OktaApiException>(() => testClient.AuthorizationServers.GetAuthorizationServerAsync(createdAuthorizationServer.Id));

            ex.StatusCode.Should().Be(404);
        }
Beispiel #17
0
        public async Task ActivateAuthorizationServer()
        {
            var testClient = TestClient.Create();
            var testAuthorizationServerName = $"{SdkPrefix}:Test AuthZ Server ({TestClient.RandomString(4)})";

            var testAuthorizationServer = new AuthorizationServer
            {
                Name        = testAuthorizationServerName,
                Description = "Test Authorization Server",
                Audiences   = new string[] { "api://default" },
            };

            var createdAuthorizationServer = await testClient.AuthorizationServers.CreateAuthorizationServerAsync(testAuthorizationServer);

            try
            {
                createdAuthorizationServer.Should().NotBeNull();
                createdAuthorizationServer.Status.Should().Be("ACTIVE");

                await testClient.AuthorizationServers.DeactivateAuthorizationServerAsync(createdAuthorizationServer.Id);

                await testClient.AuthorizationServers.ActivateAuthorizationServerAsync(createdAuthorizationServer.Id);

                var retrievedDeactivatedAuthorizationServer = await testClient.AuthorizationServers.GetAuthorizationServerAsync(createdAuthorizationServer.Id);

                retrievedDeactivatedAuthorizationServer.Status.Should().Be("ACTIVE");
            }
            finally
            {
                await createdAuthorizationServer.DeactivateAsync();

                await testClient.AuthorizationServers.DeleteAuthorizationServerAsync(createdAuthorizationServer.Id);
            }
        }
        public async Task UnassignRoleForGroup()
        {
            var client = TestClient.Create();
            var guid   = Guid.NewGuid();

            // Create group
            var createdGroup = await client.Groups.CreateGroupAsync(new CreateGroupOptions
            {
                Name = $"dotnet-sdk: {nameof(UnassignRoleForGroup)} {guid}",
            });

            try
            {
                var role = await createdGroup.AssignRoleAsync(new AssignRoleRequest
                {
                    Type = RoleType.UserAdmin,
                });

                var roles = await client.Groups.ListGroupAssignedRoles(createdGroup.Id).ToListAsync();

                roles.Should().NotBeNullOrEmpty();
                roles.Should().Contain(x => x.Id == role.Id);

                await client.Groups.RemoveRoleFromGroupAsync(createdGroup.Id, role.Id);

                roles = await client.Groups.ListGroupAssignedRoles(createdGroup.Id).ToListAsync();

                roles.Should().BeNullOrEmpty();
            }
            finally
            {
                await createdGroup.DeleteAsync();
            }
        }
Beispiel #19
0
        public async Task RetrieveUserTypeById()
        {
            var testClient = TestClient.Create();

            var testDescription = $"{SdkPrefix}:{nameof(RetrieveUserTypeById)} Test Description";
            var testDisplayName = $"{SdkPrefix}:{nameof(RetrieveUserTypeById)} Test DisplayName";
            var testName        = $"{SdkPrefix}{nameof(RetrieveUserTypeById)}_TestUserType_{TestClient.RandomString(6)}";

            var createdUserType = await testClient.UserTypes.CreateUserTypeAsync(new UserType
            {
                Description = testDescription,
                DisplayName = testDisplayName,
                Name        = testName,
            });

            try
            {
                createdUserType.Id.Should().NotBeNullOrEmpty();

                var retrievedUserType = await testClient.UserTypes.GetUserTypeAsync(createdUserType.Id);

                retrievedUserType.Should().NotBeNull();
                retrievedUserType.Id.Should().Be(createdUserType.Id);
                retrievedUserType.Description.Should().Be(testDescription);
                retrievedUserType.DisplayName.Should().Be(testDisplayName);
            }
            finally
            {
                await testClient.UserTypes.DeleteUserTypeAsync(createdUserType.Id);
            }
        }
Beispiel #20
0
        public async Task DeleteUserTypeById()
        {
            var testClient      = TestClient.Create();
            var testDescription = $"{SdkPrefix}:{nameof(DeleteUserTypeById)} Test Description";
            var testDisplayName = $"{SdkPrefix}:{nameof(DeleteUserTypeById)} Test DisplayName";
            var testName        = $"{SdkPrefix}_{nameof(DeleteUserTypeById)}_TestUserType_{TestClient.RandomString(6)}";

            var createdUserType = await testClient.UserTypes.CreateUserTypeAsync(new UserType
            {
                Description = testDescription,
                DisplayName = testDisplayName,
                Name        = testName,
            });

            createdUserType.Id.Should().NotBeNullOrEmpty();

            var retrievedUserType = await testClient.UserTypes.GetUserTypeAsync(createdUserType.Id);

            retrievedUserType.Id.Should().Be(createdUserType.Id);

            await testClient.UserTypes.DeleteUserTypeAsync(createdUserType.Id);

            var ex = await Assert.ThrowsAsync <OktaApiException>(() =>
                                                                 testClient.UserTypes.GetUserTypeAsync(createdUserType.Id));

            ex.StatusCode.Should().Be(404);
        }
Beispiel #21
0
        [Trait("Category", "NoBacon")] // Tests that don't run on internal CI pipeline
        public async Task GetLogsBySinceDate()
        {
            var client = TestClient.Create();

            // Create an Application so there is something in the logs
            var createdApp = await client.Applications.CreateApplicationAsync(new CreateBasicAuthApplicationOptions()
            {
                Label   = $"dotnet-sdk: GetLogsBySinceDate {Guid.NewGuid()}",
                Url     = "https://example.com/login.html",
                AuthUrl = "https://example.com/auth.html",
            });

            try
            {
                var until = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
                var since = DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-ddTHH:mm:ssZ");
                var logs  = await client.Logs.GetLogs(until, since).ToList();

                logs.Should().NotBeNullOrEmpty();
            }
            finally
            {
                await client.Applications.DeactivateApplicationAsync(createdApp.Id);

                await client.Applications.DeleteApplicationAsync(createdApp.Id);
            }
        }
        public async Task UpdateOrgSettings()
        {
            var client = TestClient.Create();
            var guid   = Guid.NewGuid();

            var orgSettings = await client.Orgs.GetOrgSettingsAsync();

            orgSettings.PhoneNumber = "+1-555-415-1337";
            orgSettings.Address1    = "301 Brannan St.";
            orgSettings.Address2    = guid.ToString();

            IOrgSetting updatedOrgSettings = null;

            try
            {
                updatedOrgSettings = await client.Orgs.UpdateOrgSettingAsync(orgSettings);

                updatedOrgSettings.PhoneNumber.Should().Be("+1-555-415-1337");
                updatedOrgSettings.Address1.Should().Be("301 Brannan St.");
                updatedOrgSettings.Address2.Should().Be(guid.ToString());
            }
            finally
            {
                updatedOrgSettings.PhoneNumber = string.Empty;
                updatedOrgSettings.Address1    = string.Empty;
                updatedOrgSettings.Address2    = string.Empty;
                await client.Orgs.UpdateOrgSettingAsync(updatedOrgSettings);
            }
        }
Beispiel #23
0
        [Trait("Category", "NoBacon")] // Tests that don't run on internal CI pipeline
        public async Task GetLogsByQueryString()
        {
            var client = TestClient.Create();
            var guid   = Guid.NewGuid();
            // Create an Application so there is something in the logs
            var createdApp = await client.Applications.CreateApplicationAsync(new CreateBasicAuthApplicationOptions()
            {
                Label   = $"dotnet-sdk: GetLogsByQueryString {guid}",
                Url     = "https://example.com/login.html",
                AuthUrl = "https://example.com/auth.html",
            });

            await Task.Delay(5000);

            try
            {
                var query = $"dotnet-sdk: GetLogsByQueryString";
                var logs  = await client.Logs.GetLogs(null, null, null, query).ToList();

                logs.Should().NotBeNullOrEmpty();
            }
            finally
            {
                await client.Applications.DeactivateApplicationAsync(createdApp.Id);

                await client.Applications.DeleteApplicationAsync(createdApp.Id);
            }
        }
Beispiel #24
0
        public async Task GetGroup()
        {
            var client = TestClient.Create();
            var guid   = Guid.NewGuid();

            var createdGroup = await client.Groups.CreateGroupAsync(new CreateGroupOptions
            {
                Name = $"dotnet-sdk: Get Test Group {guid}",
            });

            try
            {
                var retrievedById = await client.Groups.GetGroupAsync(createdGroup.Id);

                retrievedById.Id.Should().Be(createdGroup.Id);
            }
            finally
            {
                await createdGroup.DeleteAsync();
            }

            // Getting by ID should result in 404 error
            await Assert.ThrowsAsync <OktaApiException>(
                () => client.Groups.GetGroupAsync(createdGroup.Id));
        }
        public async Task DeactivateOrigin()
        {
            var client = TestClient.Create();
            var guid   = Guid.NewGuid();
            var testTrustedOriginName = $"{dotnetSdkPrefix}_{nameof(ActivateOrigin)}_{guid}_Test";
            var createdTrustedOrigin  = await client.TrustedOrigins.CreateOriginAsync(
                new TrustedOrigin
            {
                Name   = testTrustedOriginName,
                Origin = "http://example.com",
                Scopes = new List <IScope>()
                {
                    new Scope()
                    {
                        Type = ScopeType.Cors,
                    },
                    new Scope()
                    {
                        Type = ScopeType.Redirect,
                    },
                },
            });

            try
            {
                createdTrustedOrigin.Status.Should().Be("ACTIVE");
                var deactivatedTrustedOrigin = await client.TrustedOrigins.DeactivateOriginAsync(createdTrustedOrigin.Id);

                deactivatedTrustedOrigin.Status.Should().Be("INACTIVE");
            }
            finally
            {
                await client.TrustedOrigins.DeleteOriginAsync(createdTrustedOrigin.Id);
            }
        }
        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 = "******",
            });

            try
            {
                var factors = await createdUser.Factors.ToArray();

                factors.Count().Should().Be(0);
            }
            finally
            {
                await createdUser.DeactivateAsync();

                await createdUser.DeactivateOrDeleteAsync();
            }
        }
        public async Task GetDomain()
        {
            var oktaClient = TestClient.Create();
            var domainsClient = oktaClient.Domains;
            var domainName = $"domain{new Random().Next(1000000)}.example.com";
            var newDomain = new Domain
            {
                DomainName = domainName,
                CertificateSourceType = DomainCertificateSourceType.Manual,
            };

            var createDomainResult = await domainsClient.CreateDomainAsync(newDomain);

            // Find the domain among all domains
            var domainList = await domainsClient.ListDomainsAsync();
            domainList.Domains.Should().Contain(x => x.DomainName == domainName);

            // Get the domain by Id
            var getDomainResult = await domainsClient.GetDomainAsync(createDomainResult.Id);
            getDomainResult.Id.Should().Be(createDomainResult.Id);
            getDomainResult.DomainName.Should().Be(createDomainResult.DomainName);
            getDomainResult.CertificateSourceType.Should().Be(createDomainResult.CertificateSourceType);
            getDomainResult.ValidationStatus.Should().Be(createDomainResult.ValidationStatus);

            await domainsClient.DeleteDomainAsync(createDomainResult.Id);

            domainList = await domainsClient.ListDomainsAsync();
            domainList.Domains.Should().NotContain(x => x.DomainName == domainName);
            await Assert.ThrowsAsync<OktaApiException>(() => domainsClient.GetDomainAsync(createDomainResult.Id));
        }
        public async Task ActivateInlineHook()
        {
            var testClient         = TestClient.Create();
            var testInlineHookName = $"{SdkPrefix}:{nameof(ActivateInlineHook)} Test Inline Hook Name ({TestClient.RandomString(6)})";

            var createdInlineHook = await testClient.InlineHooks.CreateInlineHookAsync(new InlineHook
            {
                Name    = testInlineHookName,
                Version = "1.0.0",
                Type    = "com.okta.oauth2.tokens.transform",
                Channel = new InlineHookChannel
                {
                    Type    = "HTTP",
                    Version = "1.0.0",
                    Config  = new InlineHookChannelConfig
                    {
                        Uri     = "https://www.example.com/inlineHook",
                        Headers = new List <IInlineHookChannelConfigHeaders>
                        {
                            new InlineHookChannelConfigHeaders
                            {
                                Key   = "X-Test-Header",
                                Value = "Test header value",
                            },
                        },
                        AuthScheme = new InlineHookChannelConfigAuthScheme
                        {
                            Type  = "HEADER",
                            Key   = "Authorization",
                            Value = "Test-Api-Key",
                        },
                    },
                },
            });

            try
            {
                createdInlineHook.Id.Should().NotBeNullOrEmpty();
                createdInlineHook.Status.Should().Be(InlineHookStatus.Active);

                await testClient.InlineHooks.DeactivateInlineHookAsync(createdInlineHook.Id);

                var retrievedInlineHook = await testClient.InlineHooks.GetInlineHookAsync(createdInlineHook.Id);

                retrievedInlineHook.Status.Should().Be(InlineHookStatus.Inactive);

                await testClient.InlineHooks.ActivateInlineHookAsync(createdInlineHook.Id);

                var reactivatedInlineHook = await testClient.InlineHooks.GetInlineHookAsync(createdInlineHook.Id);

                reactivatedInlineHook.Status.Should().Be(InlineHookStatus.Active);
            }
            finally
            {
                await testClient.InlineHooks.DeactivateInlineHookAsync(createdInlineHook.Id);

                await testClient.InlineHooks.DeleteInlineHookAsync(createdInlineHook.Id);
            }
        }
        public async Task ShowEndUserFooterAsync()
        {
            var client = TestClient.Create();

            var orgPreferences = await client.Orgs.ShowOktaUiFooterAsync();

            orgPreferences.ShowEndUserFooter.Should().BeTrue();
        }
        public async Task ListFeatures()
        {
            var client   = TestClient.Create();
            var features = await client.Features.ListFeatures().ToListAsync();

            features.Should().NotBeNull();
            features.Count.Should().BeGreaterThan(0);
        }