Skip to content

Commit

Permalink
Merge pull request #48 from eBay/dev
Browse files Browse the repository at this point in the history
Release 2.0.3: Upgrade RestSharp from 110.2.0 to 112.0.0
  • Loading branch information
LokeshRishi authored Oct 22, 2024
2 parents 06565ea + 2775c80 commit 82b3a83
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 17 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ version of the .NET Standard.

# Add the eBay.OAuth.Client NuGet Package

**Current Version** : 2.0.2
**Current Version** : 2.0.3

Use of this source code is governed by [Apache-2.0
license](https://opensource.org/licenses/Apache-2.0).If you’re looking
for the latest stable version (2.0.2), you can grab it directly from
for the latest stable version (2.0.3), you can grab it directly from
NuGet.org.

``` xml
Expand All @@ -54,15 +54,15 @@ https://www.nuget.org/packages/eBay.OAuth.Client
**eBay.OAuth.Client** package:

``` xml
Install-Package eBay.OAuth.Client -Version 2.0.2
Install-Package eBay.OAuth.Client -Version 2.0.3
```

- After the command completes, open the **.csproj** file to see the
added reference:

``` xml
<ItemGroup>
<PackageReference Include="eBay.OAuth.Client" Version="2.0.2" />
<PackageReference Include="eBay.OAuth.Client" Version="2.0.3" />
</ItemGroup>
```

Expand All @@ -72,15 +72,15 @@ Install-Package eBay.OAuth.Client -Version 2.0.2
**eBay.OAuth.Client** package:

``` xml
dotnet add package eBay.OAuth.Client --version 2.0.2
dotnet add package eBay.OAuth.Client --version 2.0.3
```

- After the command completes, open the **.csproj** file to see the
added reference:

``` xml
<ItemGroup>
<PackageReference Include="eBay.OAuth.Client" Version="2.0.2" />
<PackageReference Include="eBay.OAuth.Client" Version="2.0.3" />
</ItemGroup>
```

Expand All @@ -90,15 +90,15 @@ dotnet add package eBay.OAuth.Client --version 2.0.2
**eBay.OAuth.Client** package:

``` xml
paket add eBay.OAuth.Client --version 2.0.2
paket add eBay.OAuth.Client --version 2.0.3
```

- After the command completes, open the **.csproj** file to see the
added reference:

``` xml
<ItemGroup>
<PackageReference Include="eBay.OAuth.Client" Version="2.0.2" />
<PackageReference Include="eBay.OAuth.Client" Version="2.0.3" />
</ItemGroup>
```

Expand Down Expand Up @@ -128,7 +128,7 @@ api.sandbox.ebay.com:
certid: <certid-from-developer-portal>
devid: <devid-from-developer-portal>
redirecturi: <redirect_uri-from-developer-portal>
Api.ebay.com:
api.ebay.com:
appid: <appid-from-developer-portal>
certid: <certid-from-developer-portal>
devid: <devid-from-developer-portal>
Expand Down
37 changes: 37 additions & 0 deletions Tests/eBay/ApiClient/Auth/OAuth2/OAuth2ApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
using System.Threading;
using OpenQA.Selenium.Chrome;
using System.Collections.Specialized;
using System.Net;
using System.Web;
using RestSharp;
using YamlDotNet.RepresentationModel;

namespace eBay.ApiClient.Auth.OAuth2
Expand Down Expand Up @@ -294,5 +296,40 @@ private String GetAuthorizationCode(String authorizationUrl, UserCredential user

}

[Fact]
public void HandleApiResponse_Success()
{
RestResponse response = new RestResponse
{
StatusCode = HttpStatusCode.OK,
Content = "{\"access_token\":\"dummyAccessToken123\",\"expires_in\":3600,\"refresh_token\":\"dummyRefreshToken456\",\"refresh_token_expires_in\":7200,\"token_type\":\"Bearer\",\"errorMessage\":\"No error\"}"
};

OAuthResponse oAuthResponse = oAuth2Api.HandleApiResponse(response, TokenType.APPLICATION);

Assert.NotNull(oAuthResponse);
Assert.NotNull(oAuthResponse.AccessToken);
Assert.NotNull(oAuthResponse.RefreshToken);
Assert.Equal("dummyAccessToken123", oAuthResponse.AccessToken.Token);
Assert.Equal("dummyRefreshToken456", oAuthResponse.RefreshToken.Token);
}

[Fact]
public void HandleApiResponse_Error()
{
RestResponse response = new RestResponse
{
StatusCode = HttpStatusCode.BadRequest,
Content = "Error in fetching the token."
};

OAuthResponse oAuthResponse = oAuth2Api.HandleApiResponse(response, TokenType.APPLICATION);

Assert.NotNull(oAuthResponse);
Assert.Null(oAuthResponse.AccessToken);
Assert.Null(oAuthResponse.RefreshToken);
Assert.Equal("Error in fetching the token.", oAuthResponse.ErrorMessage);
}

}
}
13 changes: 8 additions & 5 deletions Tests/ebay-oauth-csharp-client-tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Selenium.Chrome.WebDriver" Version="2.45.0" />
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.12.1" />
<PackageReference Include="log4net" Version="2.0.16" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private CredentialUtil.Credentials GetCredentials(OAuthEnvironment environment)
}


private OAuthResponse HandleApiResponse(RestResponse response, TokenType tokenType)
public OAuthResponse HandleApiResponse(RestResponse response, TokenType tokenType)
{
OAuthResponse oAuthResponse = new OAuthResponse();
if (response.StatusCode != HttpStatusCode.OK)
Expand Down
4 changes: 3 additions & 1 deletion ebay-oauth-csharp-client/ebay-oauth-csharp-client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>eBay.ApiClient.Auth.oAuth2</RootNamespace>
<PackageId>eBay.OAuth.Client</PackageId>
<Version>2.0.3</Version>
</PropertyGroup>
<ItemGroup>
<Folder Include="eBay\ApiClient\Auth\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="YamlDotNet" Version="13.1.1" />
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="RestSharp" Version="112.0.0" />
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ebay-oauth-csharp-client/ebay-oauth-csharp-client.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>eBay.OAuth.Client</id>
<version>2.0.2</version>
<version>2.0.3</version>
<title>eBay OAuth C# Client</title>
<owners>eBay Inc.</owners>
<authors>Sandeep Dhiman, Lokesh Rishi</authors>
Expand Down

0 comments on commit 82b3a83

Please sign in to comment.