Skip to content

Commit 82b3a83

Browse files
authored
Merge pull request #48 from eBay/dev
Release 2.0.3: Upgrade RestSharp from 110.2.0 to 112.0.0
2 parents 06565ea + 2775c80 commit 82b3a83

File tree

6 files changed

+59
-17
lines changed

6 files changed

+59
-17
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ version of the .NET Standard.
2727

2828
# Add the eBay.OAuth.Client NuGet Package
2929

30-
**Current Version** : 2.0.2
30+
**Current Version** : 2.0.3
3131

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

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

5656
``` xml
57-
Install-Package eBay.OAuth.Client -Version 2.0.2
57+
Install-Package eBay.OAuth.Client -Version 2.0.3
5858
```
5959

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

6363
``` xml
6464
<ItemGroup>
65-
<PackageReference Include="eBay.OAuth.Client" Version="2.0.2" />
65+
<PackageReference Include="eBay.OAuth.Client" Version="2.0.3" />
6666
</ItemGroup>
6767
```
6868

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

7474
``` xml
75-
dotnet add package eBay.OAuth.Client --version 2.0.2
75+
dotnet add package eBay.OAuth.Client --version 2.0.3
7676
```
7777

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

8181
``` xml
8282
<ItemGroup>
83-
<PackageReference Include="eBay.OAuth.Client" Version="2.0.2" />
83+
<PackageReference Include="eBay.OAuth.Client" Version="2.0.3" />
8484
</ItemGroup>
8585
```
8686

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

9292
``` xml
93-
paket add eBay.OAuth.Client --version 2.0.2
93+
paket add eBay.OAuth.Client --version 2.0.3
9494
```
9595

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

9999
``` xml
100100
<ItemGroup>
101-
<PackageReference Include="eBay.OAuth.Client" Version="2.0.2" />
101+
<PackageReference Include="eBay.OAuth.Client" Version="2.0.3" />
102102
</ItemGroup>
103103
```
104104

@@ -128,7 +128,7 @@ api.sandbox.ebay.com:
128128
certid: <certid-from-developer-portal>
129129
devid: <devid-from-developer-portal>
130130
redirecturi: <redirect_uri-from-developer-portal>
131-
Api.ebay.com:
131+
api.ebay.com:
132132
appid: <appid-from-developer-portal>
133133
certid: <certid-from-developer-portal>
134134
devid: <devid-from-developer-portal>

Tests/eBay/ApiClient/Auth/OAuth2/OAuth2ApiTest.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
using System.Threading;
2626
using OpenQA.Selenium.Chrome;
2727
using System.Collections.Specialized;
28+
using System.Net;
2829
using System.Web;
30+
using RestSharp;
2931
using YamlDotNet.RepresentationModel;
3032

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

295297
}
296298

299+
[Fact]
300+
public void HandleApiResponse_Success()
301+
{
302+
RestResponse response = new RestResponse
303+
{
304+
StatusCode = HttpStatusCode.OK,
305+
Content = "{\"access_token\":\"dummyAccessToken123\",\"expires_in\":3600,\"refresh_token\":\"dummyRefreshToken456\",\"refresh_token_expires_in\":7200,\"token_type\":\"Bearer\",\"errorMessage\":\"No error\"}"
306+
};
307+
308+
OAuthResponse oAuthResponse = oAuth2Api.HandleApiResponse(response, TokenType.APPLICATION);
309+
310+
Assert.NotNull(oAuthResponse);
311+
Assert.NotNull(oAuthResponse.AccessToken);
312+
Assert.NotNull(oAuthResponse.RefreshToken);
313+
Assert.Equal("dummyAccessToken123", oAuthResponse.AccessToken.Token);
314+
Assert.Equal("dummyRefreshToken456", oAuthResponse.RefreshToken.Token);
315+
}
316+
317+
[Fact]
318+
public void HandleApiResponse_Error()
319+
{
320+
RestResponse response = new RestResponse
321+
{
322+
StatusCode = HttpStatusCode.BadRequest,
323+
Content = "Error in fetching the token."
324+
};
325+
326+
OAuthResponse oAuthResponse = oAuth2Api.HandleApiResponse(response, TokenType.APPLICATION);
327+
328+
Assert.NotNull(oAuthResponse);
329+
Assert.Null(oAuthResponse.AccessToken);
330+
Assert.Null(oAuthResponse.RefreshToken);
331+
Assert.Equal("Error in fetching the token.", oAuthResponse.ErrorMessage);
332+
}
333+
297334
}
298335
}

Tests/ebay-oauth-csharp-client-tests.csproj

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
11-
<PackageReference Include="xunit" Version="2.3.1" />
12-
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
13-
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
11+
<PackageReference Include="xunit" Version="2.4.2" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14+
<PrivateAssets>all</PrivateAssets>
15+
</PackageReference>
1416
<PackageReference Include="Selenium.Chrome.WebDriver" Version="2.45.0" />
15-
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
17+
<PackageReference Include="Selenium.WebDriver" Version="4.12.1" />
18+
<PackageReference Include="log4net" Version="2.0.16" />
1619
</ItemGroup>
1720

1821
<ItemGroup>

ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/OAuth2Api.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ private CredentialUtil.Credentials GetCredentials(OAuthEnvironment environment)
274274
}
275275

276276

277-
private OAuthResponse HandleApiResponse(RestResponse response, TokenType tokenType)
277+
public OAuthResponse HandleApiResponse(RestResponse response, TokenType tokenType)
278278
{
279279
OAuthResponse oAuthResponse = new OAuthResponse();
280280
if (response.StatusCode != HttpStatusCode.OK)

ebay-oauth-csharp-client/ebay-oauth-csharp-client.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
<PropertyGroup>
33
<TargetFramework>net6.0</TargetFramework>
44
<RootNamespace>eBay.ApiClient.Auth.oAuth2</RootNamespace>
5+
<PackageId>eBay.OAuth.Client</PackageId>
6+
<Version>2.0.3</Version>
57
</PropertyGroup>
68
<ItemGroup>
79
<Folder Include="eBay\ApiClient\Auth\" />
810
</ItemGroup>
911
<ItemGroup>
1012
<PackageReference Include="YamlDotNet" Version="13.1.1" />
11-
<PackageReference Include="RestSharp" Version="110.2.0" />
13+
<PackageReference Include="RestSharp" Version="112.0.0" />
1214
<PackageReference Include="log4net" Version="2.0.15" />
1315
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
1416
</ItemGroup>

ebay-oauth-csharp-client/ebay-oauth-csharp-client.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package >
33
<metadata>
44
<id>eBay.OAuth.Client</id>
5-
<version>2.0.2</version>
5+
<version>2.0.3</version>
66
<title>eBay OAuth C# Client</title>
77
<owners>eBay Inc.</owners>
88
<authors>Sandeep Dhiman, Lokesh Rishi</authors>

0 commit comments

Comments
 (0)