Skip to content

Commit

Permalink
Merge pull request #36 from okta/dev
Browse files Browse the repository at this point in the history
Release 2.0.0.
  • Loading branch information
laura-rodriguez authored Jul 6, 2020
2 parents c88ede6 + d8ed7e4 commit 6bf77eb
Show file tree
Hide file tree
Showing 25 changed files with 268 additions and 83 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: csharp
mono: latest
# https://github.com/travis-ci/travis-ci/issues/9703
# .NET Core
dotnet: 2.1.300
dotnet: 3.1
script:
- ./build.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.4.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="Okta.Sdk" Version="1.1.0" />
<PackageReference Include="Okta.Sdk" Version="2.0.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>
Expand Down
21 changes: 8 additions & 13 deletions Okta.Auth.Sdk.UnitTests/Okta.Auth.Sdk.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="NSubstitute" Version="3.1.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Okta.Auth.Sdk\Okta.Auth.Sdk.csproj" />
<ProjectReference Include="..\Okta.Sdk.Abstractions\Okta.Sdk.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="NSubstitute">
<HintPath>..\..\..\Users\laura.rodriguez\.nuget\packages\nsubstitute\3.1.0\lib\netstandard1.3\NSubstitute.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
16 changes: 8 additions & 8 deletions Okta.Auth.Sdk.sln
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2046
# Visual Studio Version 16
VisualStudioVersion = 16.0.29519.87
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Okta.Sdk.Abstractions", "Okta.Sdk.Abstractions\Okta.Sdk.Abstractions.csproj", "{55BBE5EC-6D9A-4B4E-888A-424DDAEFE4AA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Okta.Sdk.Abstractions.UnitTests", "Okta.Sdk.Abstractions.UnitTests\Okta.Sdk.Abstractions.UnitTests.csproj", "{5222746D-BA58-4BAB-83F8-28321450784B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Okta.Auth.Sdk.UnitTests", "Okta.Auth.Sdk.UnitTests\Okta.Auth.Sdk.UnitTests.csproj", "{69F3D20F-5C23-481A-9185-59CA51D7C91C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Okta.Auth.Sdk.IntegrationTests", "Okta.Auth.Sdk.IntegrationTests\Okta.Auth.Sdk.IntegrationTests.csproj", "{780E8F5A-0E85-4D2A-9AAA-19CD16FC86B8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Okta.Auth.Sdk", "Okta.Auth.Sdk\Okta.Auth.Sdk.csproj", "{C13343AA-549D-4D49-AC2F-239700469102}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Okta.Auth.Sdk.UnitTests", "Okta.Auth.Sdk.UnitTests\Okta.Auth.Sdk.UnitTests.csproj", "{42DEF79C-A773-4A03-9C37-E6DEDC7555B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -27,10 +27,6 @@ Global
{5222746D-BA58-4BAB-83F8-28321450784B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5222746D-BA58-4BAB-83F8-28321450784B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5222746D-BA58-4BAB-83F8-28321450784B}.Release|Any CPU.Build.0 = Release|Any CPU
{69F3D20F-5C23-481A-9185-59CA51D7C91C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69F3D20F-5C23-481A-9185-59CA51D7C91C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69F3D20F-5C23-481A-9185-59CA51D7C91C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69F3D20F-5C23-481A-9185-59CA51D7C91C}.Release|Any CPU.Build.0 = Release|Any CPU
{780E8F5A-0E85-4D2A-9AAA-19CD16FC86B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{780E8F5A-0E85-4D2A-9AAA-19CD16FC86B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{780E8F5A-0E85-4D2A-9AAA-19CD16FC86B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -39,6 +35,10 @@ Global
{C13343AA-549D-4D49-AC2F-239700469102}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C13343AA-549D-4D49-AC2F-239700469102}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C13343AA-549D-4D49-AC2F-239700469102}.Release|Any CPU.Build.0 = Release|Any CPU
{42DEF79C-A773-4A03-9C37-E6DEDC7555B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{42DEF79C-A773-4A03-9C37-E6DEDC7555B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{42DEF79C-A773-4A03-9C37-E6DEDC7555B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{42DEF79C-A773-4A03-9C37-E6DEDC7555B3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
3 changes: 1 addition & 2 deletions Okta.Auth.Sdk/AuthenticationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected AuthenticationClient(IDataStore dataStore, OktaClientConfiguration con
Context = new AuthenticationRequestContext()
{
DeviceToken = authenticateOptions.DeviceToken,
}
},
};

var request = new HttpRequest
Expand Down Expand Up @@ -113,7 +113,6 @@ protected AuthenticationClient(IDataStore dataStore, OktaClientConfiguration con
{
Uri = "/api/v1/authn",
Payload = authenticationRequest,

};

if (!string.IsNullOrEmpty(authenticateOptions.UserAgent))
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions Okta.Auth.Sdk/Okta.Auth.Sdk.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard1.3</TargetFramework>
<Version>1.1.0</Version>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<Version>2.0.0</Version>
</PropertyGroup>

<PropertyGroup>
<Description>Official .NET SDK for the Okta Authentication API.</Description>
<DocumentationFile>bin\$(Configuration)\netstandard1.3\Okta.Auth.Sdk.xml</DocumentationFile>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Okta.Auth.Sdk.xml</DocumentationFile>
<RepositoryUrl>https://github.com/okta/okta-auth-dotnet</RepositoryUrl>
<PackageProjectUrl>https://github.com/okta/okta-auth-dotnet</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/okta/okta-auth-dotnet/blob/master/LICENSE</PackageLicenseUrl>
Expand All @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
63 changes: 63 additions & 0 deletions Okta.Sdk.Abstractions.UnitTests/UserAgentHelperShould.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Text;
using FluentAssertions;
using Xunit;

namespace Okta.Sdk.Abstractions.UnitTests
{
public class UserAgentHelperShould
{
[Theory]
[InlineData("foo")]
[InlineData("foo .NET")]
[InlineData(".NET")]
[InlineData(".NET foo")]
[InlineData(".NET Framework 4.8")]
public void ReturnPassedFrameworkDescriptionIfItDoesNotStartWithKeyword(string runtimeDescription)
{
// Keyword for runtimeDescription = ".NET Core"
var frameworkInfo = UserAgentHelper.GetRuntimeVersion(runtimeDescription);

frameworkInfo.Should().Be(runtimeDescription);
}

[Theory]
[InlineData("file:///C:/Program Files/dotnet/shared/Microsoft.NETCore.App/2.0.9/System.Private.CoreLib.dll", "2.0.9")]
[InlineData("Microsoft.NETCore.App/2.0.9/System.Private.CoreLib.dll", "2.0.9")]
[InlineData("foo/Microsoft.NETCore.App/2.0.9/System.Private.CoreLib.dll", "2.0.9")]
[InlineData("foo/Microsoft.NETCore.App/3.1.1/System.Private.CoreLib.dll", "3.1.1")]
public void ReturnNormalizedFrameworkDescriptionWhenItStartsWithKeywordAndCodeBaseHasKeyword(string runtimeAssemblyCodeBase, string expectedVersion)
{
// Keyword for runtimeDescription = ".NET Core"
// Keyword for codeBase = "Microsoft.NETCore.App"
var frameworkInfo = UserAgentHelper.GetRuntimeVersion(".NET Core", runtimeAssemblyCodeBase);

frameworkInfo.Should().Be($".NET Core {expectedVersion}");
}

[Theory]
[InlineData("Microsoft.App/2.0.9/System.Private.CoreLib.dll")]
[InlineData("foo/Microsoft.NETCore.foo/2.0.9/System.Private.CoreLib.dll")]
[InlineData("foo/Microsoft.NETCore.Apps/3.1.1/System.Private.CoreLib.dll")]
public void ReturnPassedFrameworkDescriptionWhenAssemblyCodeBaseDoesNotContainKeyword(string runtimeAssemblyCodeBase)
{
// Keyword for runtimeDescription = ".NET Core"
// Keyword for codeBase = "Microsoft.NETCore.App"
var frameworkInfo = UserAgentHelper.GetRuntimeVersion(".NET Core foo", runtimeAssemblyCodeBase);

frameworkInfo.Should().Be(".NET Core foo");
}

[Fact]
public void ReturnPassedFrameworkDescriptionWhenAssemblyCodeBaseContainsKeywordButNotVersion()
{
// Keyword for runtimeDescription = ".NET Core"
// Keyword for codeBase = "Microsoft.NETCore.App"
var frameworkInfo = UserAgentHelper.GetRuntimeVersion(".NET Core foo", "foo/Microsoft.NETCore.App");

frameworkInfo.Should().Be(".NET Core foo");
}
}
}

6 changes: 6 additions & 0 deletions Okta.Sdk.Abstractions/AbstractResourceTypeResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ namespace Okta.Sdk.Abstractions.Internal
/// <typeparam name="T">The base type of resource to resolve.</typeparam>
public abstract class AbstractResourceTypeResolver<T> : IResourceTypeResolver
{
/// <summary>
/// The resource type resolver factory.
/// </summary>
protected AbstractResourceTypeResolverFactory _resourceTypeResolverFactory;

/// <summary>
/// Gets or sets a resource type resolver factory.
/// </summary>
public abstract AbstractResourceTypeResolverFactory ResourceTypeResolverFactory
{
get;
Expand Down
30 changes: 30 additions & 0 deletions Okta.Sdk.Abstractions/AbstractResourceTypeResolverFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@

namespace Okta.Sdk.Abstractions
{
/// <summary>
/// This class encapsulates the logic to resolve resource types.
/// </summary>
public class AbstractResourceTypeResolverFactory
{
/// <summary>
/// Initializes a new instance of the <see cref="AbstractResourceTypeResolverFactory"/> class.
/// </summary>
/// <param name="resourceDefinedTypes">The resource types.</param>
public AbstractResourceTypeResolverFactory(IEnumerable<TypeInfo> resourceDefinedTypes)
{
_resourceDefinedTypes = resourceDefinedTypes;
Expand Down Expand Up @@ -42,24 +49,47 @@ public AbstractResourceTypeResolverFactory(IEnumerable<TypeInfo> resourceDefined
.ToArray();
}

/// <summary>
/// Gets all resource types.
/// </summary>
/// <returns>The enumeration of resource types. </returns>
public IEnumerable<TypeInfo> GetAllResourceDefinedTypes()
{
return _resourceDefinedTypes;
}

/// <summary>
/// Gets all resolvers.
/// </summary>
/// <returns>The anumeration of resolvers.</returns>
protected IEnumerable<(Type Resolver, Type For)> GetAllResolvers()
{
var resolvers = GetAllResolvers(GetAllResourceDefinedTypes());

return resolvers;
}

/// <summary>
/// Indicates if a resource type requires resolution.
/// </summary>
/// <param name="resourceType">The resource type.</param>
/// <returns> A bool value indicating if the resource type requires resolution.</returns>
public bool RequiresResolution(Type resourceType)
=> GetResolver(resourceType) != null;

/// <summary>
/// Creates a new resolver.
/// </summary>
/// <typeparam name="T">The resolver type.</typeparam>
/// <returns>The resolver.</returns>
public IResourceTypeResolver CreateResolver<T>()
=> CreateResolver(forType: typeof(T));

/// <summary>
/// Creates a new resolver for a given type.
/// </summary>
/// <param name="forType">The resource type.</param>
/// <returns>The resolver.</returns>
public IResourceTypeResolver CreateResolver(Type forType)
{
var concreteType = GetConcreteForInterface(forType);
Expand Down
15 changes: 15 additions & 0 deletions Okta.Sdk.Abstractions/BaseOktaClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,19 @@

namespace Okta.Sdk.Abstractions
{
/// <summary>
/// Base OktaClient implementation of <see cref="IOktaClient"/>.
/// </summary>
public class BaseOktaClient : IOktaClient
{
/// <summary>
/// The <code>IDataStore</code> implementation to be used for making requests.
/// </summary>
protected IDataStore _dataStore;

/// <summary>
/// The request context to be used when making requests.
/// </summary>
protected RequestContext _requestContext;

static BaseOktaClient()
Expand Down Expand Up @@ -87,6 +97,11 @@ protected BaseOktaClient(IDataStore dataStore, OktaClientConfiguration configura
_requestContext = requestContext;
}

/// <summary>
/// Gets the Okta client configuration.
/// </summary>
/// <param name="apiClientConfiguration">The client configuration</param>
/// <returns>An instance of <c>OktaClientConfiguration</c></returns>
protected static OktaClientConfiguration GetConfigurationOrDefault(OktaClientConfiguration apiClientConfiguration = null)
{
string configurationFileRoot = Directory.GetCurrentDirectory();
Expand Down
14 changes: 14 additions & 0 deletions Okta.Sdk.Abstractions/BaseResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@

namespace Okta.Sdk.Abstractions
{
/// <summary>
/// Base resource implementation for <see cref="IResource"/>.
/// </summary>
public class BaseResource : IResource
{
internal static readonly TypeInfo ResourceTypeInfo = typeof(IResource).GetTypeInfo();

/// <summary>
/// The Okta client.
/// </summary>
protected IOktaClient _client;

private ResourceFactory _resourceFactory;
private ILogger _logger;
private IDictionary<string, object> _data;
Expand All @@ -29,6 +36,13 @@ public BaseResource()
Initialize(null, null, null, null);
}

/// <summary>
/// Initializes a resource.
/// </summary>
/// <param name="client">The Okta client.</param>
/// <param name="resourceFactory">The resource factory.</param>
/// <param name="data">The resource data.</param>
/// <param name="logger">The logger.</param>
public void Initialize(
IOktaClient client,
ResourceFactory resourceFactory,
Expand Down
Loading

0 comments on commit 6bf77eb

Please sign in to comment.