Skip to content

Commit

Permalink
Factors API (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
lboyette-okta authored Nov 28, 2017
1 parent 43f35f7 commit f3902c0
Show file tree
Hide file tree
Showing 143 changed files with 2,858 additions and 223 deletions.
121 changes: 93 additions & 28 deletions package-lock.json

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

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
{
"name": "okta-sdk-dotnet",
"version": "0.0.0",
"main": "index.js",
"private": true,
"scripts": {
"generate": "okta-sdk-generator -o src/Okta.Sdk/ -t templates",
"test-server": "node test-server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/okta/oktasdk-csharp.git"
"url": "git+https://github.com/okta/oktasdk-sdk-dotnet.git"
},
"bugs": {
"url": "https://github.com/okta/oktasdk-csharp/issues"
"url": "https://github.com/okta/oktasdk-sdk-dotnet/issues"
},
"homepage": "https://github.com/okta/oktasdk-csharp#readme",
"homepage": "https://github.com/okta/oktasdk-sdk-dotnet#readme",
"devDependencies": {
"@okta/openapi": "0.3.0",
"@okta/openapi": "0.8.0",
"json-stable-stringify": "^1.0.1",
"lodash": "^4.17.4"
}
Expand Down
94 changes: 94 additions & 0 deletions src/Okta.Sdk.IntegrationTests/FactorScenarios.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// <copyright file="FactorScenarios.cs" company="Okta, Inc">
// Copyright (c) 2014-2017 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.Linq;
using System.Text;
using System.Threading.Tasks;
using FluentAssertions;
using Xunit;

namespace Okta.Sdk.IntegrationTests
{
[Collection(nameof(ScenariosCollection))]
public class FactorScenarios : ScenarioGroup
{
[Fact]
public async Task CreateSecurityQuestionFactor()
{
var client = GetClient("factor-securityquestion-create");

var profile = new UserProfile
{
FirstName = "Jill",
LastName = "Factor-SecurityQuestion",
Email = "[email protected]",
Login = "[email protected]",
};
profile["nickName"] = "jill-factor-securityquestion";

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

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

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

var securityQuestionFactor = await createdUser.ListFactors().OfType<ISecurityQuestionFactor>().FirstOrDefault();
securityQuestionFactor.Should().NotBeNull();
securityQuestionFactor.Profile.Question.Should().Be("disliked_food");
securityQuestionFactor.Profile.QuestionText.Should().NotBeNullOrEmpty();
}
finally
{
await createdUser.DeactivateAsync();
await createdUser.DeactivateOrDeleteAsync();
}
}

[Fact]
public async Task ListFactorsForNewUser()
{
var client = GetClient("list-factors");

var profile = new UserProfile
{
FirstName = "Jack",
LastName = "List-Factors",
Email = "[email protected]",
Login = "[email protected]",
};
profile["nickName"] = "jack-list-users";

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

try
{
var factors = await createdUser.Factors.ToArray();
factors.Count().Should().Be(0);
}
finally
{
await createdUser.DeactivateAsync();
await createdUser.DeactivateOrDeleteAsync();
}
}
}
}
2 changes: 1 addition & 1 deletion src/Okta.Sdk.IntegrationTests/GroupScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// </copyright>

using System;
using System.Linq;
using System.Threading.Tasks;
using FluentAssertions;
using Xunit;
using System.Linq;

namespace Okta.Sdk.IntegrationTests
{
Expand Down
Loading

0 comments on commit f3902c0

Please sign in to comment.