Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Commit

Permalink
require options at client classes
Browse files Browse the repository at this point in the history
  • Loading branch information
leastprivilege committed Aug 30, 2019
1 parent d6bb721 commit 305ec2a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
7 changes: 5 additions & 2 deletions src/Client/IntrospectionClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
Expand Down Expand Up @@ -31,7 +34,7 @@ public IntrospectionClient(HttpMessageInvoker client, IntrospectionClientOptions
public IntrospectionClient(Func<HttpMessageInvoker> client, IntrospectionClientOptions options)
{
_client = client ?? throw new ArgumentNullException(nameof(client));
_options = options ?? new IntrospectionClientOptions();
_options = options ?? throw new ArgumentNullException(nameof(options));
}

/// <summary>
Expand Down
7 changes: 5 additions & 2 deletions src/Client/TokenClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
Expand Down Expand Up @@ -33,7 +36,7 @@ public TokenClient(HttpMessageInvoker client, TokenClientOptions options)
public TokenClient(Func<HttpMessageInvoker> client, TokenClientOptions options)
{
_client = client ?? throw new ArgumentNullException(nameof(client));
_options = options ?? new TokenClientOptions();
_options = options ?? throw new ArgumentNullException(nameof(options));
}

/// <summary>
Expand Down
12 changes: 6 additions & 6 deletions test/UnitTests/TokenClientRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public async Task Password_request_without_password_should_have_correct_format()
[Fact]
public void Password_request_without_username_should_fail()
{
var tokenClient = new TokenClient(_client, null);
var tokenClient = new TokenClient(_client, new TokenClientOptions());

Func<Task> act = async () => await tokenClient.RequestPasswordTokenAsync(userName: null);

Expand Down Expand Up @@ -167,7 +167,7 @@ public async Task Code_request_should_have_correct_format()
[Fact]
public void Code_request_without_code_should_fail()
{
var tokenClient = new TokenClient(_client, null);
var tokenClient = new TokenClient(_client, new TokenClientOptions());

Func<Task> act = async () => await tokenClient.RequestAuthorizationCodeTokenAsync(code: null, redirectUri: "uri", codeVerifier: "verifier");

Expand All @@ -177,7 +177,7 @@ public void Code_request_without_code_should_fail()
[Fact]
public void Code_request_without_redirect_uri_should_fail()
{
var tokenClient = new TokenClient(_client, null);
var tokenClient = new TokenClient(_client, new TokenClientOptions());

Func<Task> act = async () => await tokenClient.RequestAuthorizationCodeTokenAsync(code: "code", redirectUri: null, codeVerifier: "verifier");

Expand Down Expand Up @@ -207,7 +207,7 @@ public async Task Refresh_request_should_have_correct_format()
[Fact]
public void Refresh_request_without_refresh_token_should_fail()
{
var tokenClient = new TokenClient(_client, null);
var tokenClient = new TokenClient(_client, new TokenClientOptions());

Func<Task> act = async () => await tokenClient.RequestRefreshTokenAsync(refreshToken: null, scope: "scope");

Expand All @@ -217,7 +217,7 @@ public void Refresh_request_without_refresh_token_should_fail()
[Fact]
public void Setting_no_grant_type_should_fail()
{
var tokenClient = new TokenClient(_client, null);
var tokenClient = new TokenClient(_client, new TokenClientOptions());

Func<Task> act = async () => await tokenClient.RequestTokenAsync(grantType: null);

Expand All @@ -227,7 +227,7 @@ public void Setting_no_grant_type_should_fail()
[Fact]
public async Task Setting_custom_parameters_should_have_correct_format()
{
var tokenClient = new TokenClient(_client, null);
var tokenClient = new TokenClient(_client, new TokenClientOptions());

var parameters = new Dictionary<string, string>
{
Expand Down

0 comments on commit 305ec2a

Please sign in to comment.