Skip to content

Commit 711b181

Browse files
authored
Merge pull request #41 from intuit/develop
Develop
2 parents 09be25d + 67e6f88 commit 711b181

File tree

125 files changed

+64287
-240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+64287
-240
lines changed

IPPDotNetDevKitCSV3/Code/Intuit.Ipp.Core/LogRequestsToDisk.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void LogPlatformRequests(string xml, bool isRequest)
9090
{
9191
Encoding encoder = Encoding.GetEncoding("utf-8", new EncoderExceptionFallback(), new DecoderExceptionFallback());
9292
byte[] data = encoder.GetBytes(xml);
93-
using (FileStream fs = new FileStream(filePath, FileMode.Append, FileAccess.ReadWrite))
93+
using (FileStream fs = new FileStream(filePath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
9494
{
9595
fs.Write(data, 0, data.Length);
9696
}

IPPDotNetDevKitCSV3/Code/Intuit.Ipp.GlobalTaxService/Intuit.Ipp.GlobalTaxService.csproj

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,60 +47,49 @@
4747
<HintPath>..\packages\DevDefined.OAuth.0.2\lib\DevDefined.OAuth.dll</HintPath>
4848
</Reference>
4949
<Reference Include="Intuit.Ipp.Core, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
50-
<SpecificVersion>False</SpecificVersion>
51-
<HintPath>..\..\SDK Assemblies\Intuit.Ipp.Core.dll</HintPath>
50+
<HintPath>..\packages\IppDotNetSdkForQuickBooksApiV3.5.2.0\lib\Intuit.Ipp.Core.dll</HintPath>
5251
</Reference>
5352
<Reference Include="Intuit.Ipp.Data, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
54-
<SpecificVersion>False</SpecificVersion>
55-
<HintPath>..\..\SDK Assemblies\Intuit.Ipp.Data.dll</HintPath>
53+
<HintPath>..\packages\IppDotNetSdkForQuickBooksApiV3.5.2.0\lib\Intuit.Ipp.Data.dll</HintPath>
5654
</Reference>
5755
<Reference Include="Intuit.Ipp.DataService, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
58-
<SpecificVersion>False</SpecificVersion>
59-
<HintPath>..\..\SDK Assemblies\Intuit.Ipp.DataService.dll</HintPath>
56+
<HintPath>..\packages\IppDotNetSdkForQuickBooksApiV3.5.2.0\lib\Intuit.Ipp.DataService.dll</HintPath>
6057
</Reference>
6158
<Reference Include="Intuit.Ipp.Diagnostics, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
62-
<SpecificVersion>False</SpecificVersion>
63-
<HintPath>..\..\SDK Assemblies\Intuit.Ipp.Diagnostics.dll</HintPath>
59+
<HintPath>..\packages\IppDotNetSdkForQuickBooksApiV3.5.2.0\lib\Intuit.Ipp.Diagnostics.dll</HintPath>
6460
</Reference>
6561
<Reference Include="Intuit.Ipp.Exception, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
66-
<SpecificVersion>False</SpecificVersion>
67-
<HintPath>..\..\SDK Assemblies\Intuit.Ipp.Exception.dll</HintPath>
62+
<HintPath>..\packages\IppDotNetSdkForQuickBooksApiV3.5.2.0\lib\Intuit.Ipp.Exception.dll</HintPath>
63+
</Reference>
64+
<Reference Include="Intuit.Ipp.GlobalTaxService, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
65+
<HintPath>..\packages\IppDotNetSdkForQuickBooksApiV3.5.2.0\lib\Intuit.Ipp.GlobalTaxService.dll</HintPath>
6866
</Reference>
6967
<Reference Include="Intuit.Ipp.LinqExtender, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
70-
<SpecificVersion>False</SpecificVersion>
71-
<HintPath>..\..\SDK Assemblies\Intuit.Ipp.LinqExtender.dll</HintPath>
68+
<HintPath>..\packages\IppDotNetSdkForQuickBooksApiV3.5.2.0\lib\Intuit.Ipp.LinqExtender.dll</HintPath>
7269
</Reference>
7370
<Reference Include="Intuit.Ipp.OAuth2PlatformClient, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
74-
<SpecificVersion>False</SpecificVersion>
75-
<HintPath>..\..\SDK Assemblies\Intuit.Ipp.OAuth2PlatformClient.dll</HintPath>
71+
<HintPath>..\packages\IppDotNetSdkForQuickBooksApiV3.5.2.0\lib\Intuit.Ipp.OAuth2PlatformClient.dll</HintPath>
7672
</Reference>
7773
<Reference Include="Intuit.Ipp.PlatformService, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
78-
<SpecificVersion>False</SpecificVersion>
79-
<HintPath>..\..\SDK Assemblies\Intuit.Ipp.PlatformService.dll</HintPath>
74+
<HintPath>..\packages\IppDotNetSdkForQuickBooksApiV3.5.2.0\lib\Intuit.Ipp.PlatformService.dll</HintPath>
8075
</Reference>
8176
<Reference Include="Intuit.Ipp.QueryFilter, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
82-
<SpecificVersion>False</SpecificVersion>
83-
<HintPath>..\..\SDK Assemblies\Intuit.Ipp.QueryFilter.dll</HintPath>
77+
<HintPath>..\packages\IppDotNetSdkForQuickBooksApiV3.5.2.0\lib\Intuit.Ipp.QueryFilter.dll</HintPath>
8478
</Reference>
8579
<Reference Include="Intuit.Ipp.ReportService, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
86-
<SpecificVersion>False</SpecificVersion>
87-
<HintPath>..\..\SDK Assemblies\Intuit.Ipp.ReportService.dll</HintPath>
80+
<HintPath>..\packages\IppDotNetSdkForQuickBooksApiV3.5.2.0\lib\Intuit.Ipp.ReportService.dll</HintPath>
8881
</Reference>
8982
<Reference Include="Intuit.Ipp.Retry, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
90-
<SpecificVersion>False</SpecificVersion>
91-
<HintPath>..\..\SDK Assemblies\Intuit.Ipp.Retry.dll</HintPath>
83+
<HintPath>..\packages\IppDotNetSdkForQuickBooksApiV3.5.2.0\lib\Intuit.Ipp.Retry.dll</HintPath>
9284
</Reference>
9385
<Reference Include="Intuit.Ipp.Security, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
94-
<SpecificVersion>False</SpecificVersion>
95-
<HintPath>..\..\SDK Assemblies\Intuit.Ipp.Security.dll</HintPath>
86+
<HintPath>..\packages\IppDotNetSdkForQuickBooksApiV3.5.2.0\lib\Intuit.Ipp.Security.dll</HintPath>
9687
</Reference>
9788
<Reference Include="Intuit.Ipp.Utility, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
98-
<SpecificVersion>False</SpecificVersion>
99-
<HintPath>..\..\SDK Assemblies\Intuit.Ipp.Utility.dll</HintPath>
89+
<HintPath>..\packages\IppDotNetSdkForQuickBooksApiV3.5.2.0\lib\Intuit.Ipp.Utility.dll</HintPath>
10090
</Reference>
10191
<Reference Include="Intuit.Ipp.WebHooksService, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
102-
<SpecificVersion>False</SpecificVersion>
103-
<HintPath>..\..\SDK Assemblies\Intuit.Ipp.WebHooksService.dll</HintPath>
92+
<HintPath>..\packages\IppDotNetSdkForQuickBooksApiV3.5.2.0\lib\Intuit.Ipp.WebHooksService.dll</HintPath>
10493
</Reference>
10594
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
10695
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>

IPPDotNetDevKitCSV3/Code/Intuit.Ipp.OAuth2PlatformClient.Test/App.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@
44
<add key="DiscoveryAuthority" value="https://oauth.platform.intuit.com/op/v1"/>
55
<add key="DiscoveryUrlProduction" value="https://developer.api.intuit.com/.well-known/openid_configuration"/>
66
<add key="DiscoveryUrlSandbox" value="https://developer.api.intuit.com/.well-known/openid_sandbox_configuration/"/>
7+
<add key="ClientId" value="Enter Client Id here"/>
8+
<add key="ClientSecret" value="Enter Client Secret here"/>
9+
<add key="RedirectUrl" value="http://localhost:49372/Default.aspx"/>
10+
<add key="AppEnvironment" value="Sandbox"/>
711
</appSettings>
812
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>

IPPDotNetDevKitCSV3/Code/Intuit.Ipp.OAuth2PlatformClient.Test/DiscoveryClientTests.cs

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using System.Threading.Tasks;
1010
using Intuit.Ipp.OAuth2PlatformClient;
1111
using System.Configuration;
12-
12+
using Intuit.Ipp.OAuth2PlatformClient.Helpers;
1313

1414
namespace Intuit.Ipp.OAuth2PlatformClient.UnitTests
1515
{
@@ -21,11 +21,13 @@ public class DiscoveryClientTests
2121

2222
public DiscoveryClientTests()
2323
{
24-
var discoFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Documents", "discovery.json");//Nimisha
25-
var document = File.ReadAllText(discoFileName);
24+
var binDir = AppDomain.CurrentDomain.BaseDirectory;
25+
FileInfo fileInfo = new FileInfo(binDir);
26+
DirectoryInfo dir = fileInfo.Directory.Parent.Parent;
27+
28+
var document = File.ReadAllText(Path.Combine(dir.FullName, "Intuit.Ipp.OAuth2PlatformClient.Test\\Documents", "discovery.json"));//Nimisha
2629

27-
var jwksFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Documents", "discovery.json");//Nimisha
28-
var jwks = File.ReadAllText(jwksFileName);
30+
var jwks = File.ReadAllText(Path.Combine(dir.FullName, "Intuit.Ipp.OAuth2PlatformClient.Test\\Documents", "discovery.json"));//Nimisha
2931

3032
_successHandler = new NetworkHandler(request =>
3133
{
@@ -38,6 +40,17 @@ public DiscoveryClientTests()
3840
}, HttpStatusCode.OK);
3941
}
4042

43+
[TestMethod]
44+
public void DiscoveryClientTests2()
45+
{
46+
DiscoveryClient clientTest = new DiscoveryClient(AppEnvironment.Sandbox);
47+
Assert.AreEqual("https://developer.api.intuit.com/.well-known/openid_sandbox_configuration/", clientTest.Url);
48+
49+
DiscoveryClient clientTest2 = new DiscoveryClient(AppEnvironment.Production);
50+
Assert.AreEqual("https://developer.api.intuit.com/.well-known/openid_configuration/", clientTest2.Url);
51+
52+
}
53+
4154
[TestMethod]
4255
[ExpectedException(typeof(InvalidOperationException))]
4356
public void malformed_authority_url_should_throw()
@@ -47,9 +60,6 @@ public void malformed_authority_url_should_throw()
4760

4861
//Assert.AreEqual(e.Message,("Malformed authority URL"));
4962
Assert.Fail();
50-
51-
52-
5363
}
5464

5565
[TestMethod]
@@ -97,7 +107,6 @@ public async Task TryGetValue_calls_should_behave_as_excected()
97107
var client = new DiscoveryClient(_endpoint, _successHandler);
98108
var disco = await client.GetAsync();
99109

100-
101110
Assert.AreEqual(disco.IsError, false);
102111
Assert.IsNotNull(disco.TryGetValue(OidcConstants.Discovery.AuthorizationEndpoint));
103112
Assert.AreEqual(disco.TryGetString(OidcConstants.Discovery.AuthorizationEndpoint), "https://appcenter.intuit.com/connect/oauth2");
@@ -112,15 +121,65 @@ public async Task Strongly_typed_accessors_should_behave_as_expected()
112121
var disco = await client.GetAsync();
113122

114123
Assert.AreEqual(disco.IsError, false);
115-
116124
Assert.AreEqual(disco.TokenEndpoint, "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer");
117125
Assert.AreEqual(disco.AuthorizeEndpoint, "https://appcenter.intuit.com/connect/oauth2");
118126
Assert.AreEqual(disco.UserInfoEndpoint, "https://accounts.intuit.com/v1/openid_connect/userinfo");
119127
Assert.AreEqual(disco.RevocationEndpoint, "https://developer.api.intuit.com/v2/oauth2/tokens/revoke");
120128
Assert.AreEqual(disco.JwksUri, "https://oauth.platform.intuit.com/op/v1/jwks");
129+
}
130+
131+
[TestMethod]
132+
public void Http_error_should_be_handled_correctly_Get()
133+
{
134+
var handler = new NetworkHandler(HttpStatusCode.NotFound, "not found");
135+
var client = new DiscoveryClient(_endpoint, handler);
136+
var disco = client.Get();
137+
138+
Assert.AreEqual(disco.IsError, true);
139+
Assert.AreEqual(disco.ErrorType, (ResponseErrorType.Http));
140+
Assert.AreEqual(disco.Error.StartsWith("Error connecting to"), true);
141+
Assert.AreEqual(disco.Error.EndsWith("not found"), true);
142+
Assert.AreEqual(disco.StatusCode, (HttpStatusCode.NotFound));
143+
}
144+
145+
[TestMethod]
146+
public void Exception_should_be_handled_correctly_Get()
147+
{
148+
var handler = new NetworkHandler(new Exception("error"));
149+
var client = new DiscoveryClient(_endpoint, handler);
150+
var disco = client.Get();
151+
152+
Assert.AreEqual(disco.IsError, true);
153+
Assert.AreEqual(disco.ErrorType, (ResponseErrorType.Exception));
154+
Assert.AreEqual(disco.Error.StartsWith("Error connecting to"), true);
155+
Assert.AreEqual(disco.Error.EndsWith("errors occurred."), true);
156+
}
121157

158+
[TestMethod]
159+
public void TryGetValue_calls_should_behave_as_excected_Get()
160+
{
161+
var client = new DiscoveryClient(_endpoint, _successHandler);
162+
var disco = client.Get();
163+
164+
Assert.AreEqual(disco.IsError, false);
165+
Assert.IsNotNull(disco.TryGetValue(OidcConstants.Discovery.AuthorizationEndpoint));
166+
Assert.AreEqual(disco.TryGetString(OidcConstants.Discovery.AuthorizationEndpoint), "https://appcenter.intuit.com/connect/oauth2");
167+
Assert.IsNull(disco.TryGetValue("unknown"));
168+
Assert.IsNull(disco.TryGetString("unknown"));
169+
}
122170

171+
[TestMethod]
172+
public void Strongly_typed_accessors_should_behave_as_expected_Get()
173+
{
174+
var client = new DiscoveryClient(_endpoint, _successHandler);
175+
var disco = client.Get();
123176

177+
Assert.AreEqual(disco.IsError, false);
178+
Assert.AreEqual(disco.TokenEndpoint, "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer");
179+
Assert.AreEqual(disco.AuthorizeEndpoint, "https://appcenter.intuit.com/connect/oauth2");
180+
Assert.AreEqual(disco.UserInfoEndpoint, "https://accounts.intuit.com/v1/openid_connect/userinfo");
181+
Assert.AreEqual(disco.RevocationEndpoint, "https://developer.api.intuit.com/v2/oauth2/tokens/revoke");
182+
Assert.AreEqual(disco.JwksUri, "https://oauth.platform.intuit.com/op/v1/jwks");
124183
}
125184
}
126185
}

IPPDotNetDevKitCSV3/Code/Intuit.Ipp.OAuth2PlatformClient.Test/Intuit.Ipp.OAuth2PlatformClient.Test.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<WarningLevel>4</WarningLevel>
3737
</PropertyGroup>
3838
<ItemGroup>
39-
<Reference Include="Intuit.Ipp.OAuth2PlatformClient, Version=5.1.1.0, Culture=neutral, processorArchitecture=AMD64">
39+
<Reference Include="Intuit.Ipp.OAuth2PlatformClient, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
4040
<SpecificVersion>False</SpecificVersion>
4141
<HintPath>..\..\SDK Assemblies\Intuit.Ipp.OAuth2PlatformClient.dll</HintPath>
4242
</Reference>
@@ -65,6 +65,7 @@
6565
<Compile Include="AuthorizeResponseTests.cs" />
6666
<Compile Include="DiscoveryClientTests.cs" />
6767
<Compile Include="NetworkHandler.cs" />
68+
<Compile Include="OAuth2ClientTests.cs" />
6869
<Compile Include="TokenClientTests.cs" />
6970
<Compile Include="TokenRevocationClientTests.cs" />
7071
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -80,9 +81,7 @@
8081
<None Include="Documents\success_revoketoken_response.json" />
8182
<None Include="Documents\success_token_response.json" />
8283
<None Include="Documents\success_userinfo_response.json" />
83-
<None Include="packages.config">
84-
<SubType>Designer</SubType>
85-
</None>
84+
<None Include="packages.config" />
8685
</ItemGroup>
8786
<Choose>
8887
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using Intuit.Ipp.OAuth2PlatformClient;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Threading.Tasks;
6+
using System.Configuration;
7+
using Intuit.Ipp.OAuth2PlatformClient.UnitTests;
8+
using System.Net;
9+
10+
namespace Intuit.Ipp.OAuth2PlatformClient.Tests
11+
{
12+
[TestClass()]
13+
public class OAuth2ClientTests
14+
{
15+
static string clientId = ConfigurationManager.AppSettings["ClientId"];
16+
static string clientSecret = ConfigurationManager.AppSettings["ClientSecret"];
17+
static string redirectUrl = ConfigurationManager.AppSettings["RedirectUrl"];
18+
static string appEnv = ConfigurationManager.AppSettings["AppEnvironment"];
19+
OAuth2Client client = new OAuth2Client(clientId, clientSecret, redirectUrl, appEnv);
20+
21+
[TestMethod()]
22+
public void GetAuthorizationURLTest()
23+
{
24+
List<OidcScopes> scopes = new List<OidcScopes>();
25+
scopes.Add(OidcScopes.Accounting);
26+
scopes.Add(OidcScopes.Payment);
27+
string csrfToken = CryptoRandom.CreateUniqueId();
28+
string actual = client.GetAuthorizationURL(scopes, csrfToken);
29+
30+
string expected = string.Format("https://appcenter.intuit.com/connect/oauth2?client_id={0}&response_type=code&scope=com.intuit.quickbooks.accounting%20com.intuit.quickbooks.payment&redirect_uri={1}&state={2}", client.ClientID, Uri.EscapeDataString(client.RedirectURI), client.CSRFToken);
31+
32+
Assert.AreEqual(expected, actual);
33+
}
34+
35+
[TestMethod()]
36+
public void GetAuthorizationURLTest1()
37+
{
38+
List<OidcScopes> scopes = new List<OidcScopes>();
39+
scopes.Add(OidcScopes.Accounting);
40+
scopes.Add(OidcScopes.Payment);
41+
string actual = client.GetAuthorizationURL(scopes);
42+
43+
string expected = string.Format("https://appcenter.intuit.com/connect/oauth2?client_id={0}&response_type=code&scope=com.intuit.quickbooks.accounting%20com.intuit.quickbooks.payment&redirect_uri={1}&state={2}", client.ClientID, Uri.EscapeDataString(client.RedirectURI), client.CSRFToken);
44+
45+
Assert.AreEqual(expected, actual);
46+
}
47+
48+
}
49+
}

0 commit comments

Comments
 (0)