Skip to content

Commit 07e2ee8

Browse files
Updating csharp library with new csharp OAuth signer and encryption libraries
1 parent c94e379 commit 07e2ee8

138 files changed

Lines changed: 3892 additions & 3310 deletions

File tree

Some content is hidden

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

csharp/.openapi-generator/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.3.1
1+
5.0.1

csharp/Acme.App.MastercardApi.Client.Tests/TokenizeApiTest.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
using System;
1+
using System.Security.Cryptography;
22
using Mastercard.Developer.ClientEncryption.Core.Encryption;
33
using Mastercard.Developer.ClientEncryption.Core.Utils;
4-
using Mastercard.Developer.ClientEncryption.RestSharp.Interceptors;
54
using Mastercard.Developer.OAuth1Signer.Core.Utils;
6-
using Mastercard.Developer.OAuth1Signer.RestSharp.Authenticators;
75
using Microsoft.VisualStudio.TestTools.UnitTesting;
86
using Acme.App.MastercardApi.Client.Api;
97
using Acme.App.MastercardApi.Client.Client;
108
using Acme.App.MastercardApi.Client.Model;
119
using System.Security.Cryptography.X509Certificates;
10+
using Mastercard.Developer.ClientEncryption.RestSharpV2.Interceptors;
1211
using static Mastercard.Developer.ClientEncryption.Core.Encryption.FieldLevelEncryptionConfig;
1312

1413
namespace Mastercard.Developer.DigitalEnablement.Tests
@@ -23,7 +22,11 @@ public class TokenizeApiTest
2322
private const string SigningKeyAlias = "fake-key";
2423
private const string SigningKeyPassword = "fakepassword";
2524
private const string SigningKeyPkcs12FilePath = "./_Resources/fake-signing-key.p12";
25+
private const string BasePath = "https://sandbox.api.mastercard.com/mdes/";
2626

27+
private static RSA SigningKey { set; get; }
28+
private static ApiClient Client { set; get; }
29+
2730
// Encryption keys from https://developer.mastercard.com/page/digital-enablement-api-sandbox-configuration
2831
private const string EncryptionCertificateFilePath = "./_Resources/digital-enablement-sandbox-encryption-key.crt";
2932
private const string DecryptionKeyFilePath = "./_Resources/digital-enablement-sandbox-decryption-key.key";
@@ -36,7 +39,7 @@ public static void Before(TestContext context)
3639

3740
private static void SetupApiClient()
3841
{
39-
var signingKey = AuthenticationUtils.LoadSigningKey(SigningKeyPkcs12FilePath, SigningKeyAlias, SigningKeyPassword, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);
42+
SigningKey = AuthenticationUtils.LoadSigningKey(SigningKeyPkcs12FilePath, SigningKeyAlias, SigningKeyPassword, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);
4043
var encryptionCertificate = EncryptionUtils.LoadEncryptionCertificate(EncryptionCertificateFilePath);
4144
var decryptionKey = EncryptionUtils.LoadDecryptionKey(DecryptionKeyFilePath);
4245

@@ -56,16 +59,17 @@ private static void SetupApiClient()
5659
.WithValueEncoding(FieldValueEncoding.Hex)
5760
.Build();
5861

59-
var config = Configuration.Default;
60-
config.BasePath = "https://sandbox.api.mastercard.com/mdes/";
61-
config.ApiClient.RestClient.Authenticator = new RestSharpOAuth1Authenticator(ConsumerKey, signingKey, new Uri(config.BasePath));
62-
config.ApiClient.EncryptionInterceptor = new RestSharpFieldLevelEncryptionInterceptor(fieldLevelEncryptionConfig);
62+
Client = new ApiClient(SigningKey, BasePath, ConsumerKey)
63+
{
64+
EncryptionInterceptor = new RestSharpFieldLevelEncryptionInterceptor(fieldLevelEncryptionConfig)
65+
};
6366
}
6467

6568
[TestMethod]
6669
public void TestTokenizeEndpoint()
6770
{
68-
var tokenizeApi = new TokenizeApi(Configuration.Default);
71+
var tokenizeApi = new TokenizeApi();
72+
tokenizeApi.Client = Client;
6973
var response = tokenizeApi.CreateTokenize(BuildTokenizeRequestSchema());
7074
Assert.IsNotNull(response);
7175
Assert.AreEqual("APPROVED", response.Decision);

csharp/Acme.App.MastercardApi.Client/Acme.App.MastercardApi.Client.csproj

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard1.3</TargetFramework>
4+
<TargetFramework>netstandard2.0</TargetFramework>
55
<AssemblyName>Acme.App.MastercardApi.Client</AssemblyName>
66
<PackageId>Acme.App.MastercardApi.Client</PackageId>
77
<OutputType>Library</OutputType>
@@ -18,14 +18,13 @@
1818
</PropertyGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="FubarCoder.RestSharp.Portable.Core" Version="4.0.7" />
22-
<PackageReference Include="FubarCoder.RestSharp.Portable.HttpClient" Version="4.0.7" />
21+
<PackageReference Include="JsonSubTypes" Version="1.7.0" />
2322
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
24-
<PackageReference Include="JsonSubTypes" Version="1.6.0" />
25-
<PackageReference Include="Mastercard.Developer.OAuth1Signer.RestSharp" Version="1.2.5" />
26-
<PackageReference Include="Mastercard.Developer.ClientEncryption.RestSharp" Version="1.0.2" />
27-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
23+
<PackageReference Include="RestSharp" Version="106.11.4" />
24+
<PackageReference Include="Polly" Version="7.2.0" />
25+
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
26+
<PackageReference Include="Mastercard.Developer.ClientEncryption.RestSharpV2" Version="1.1.0" />
27+
<PackageReference Include="Mastercard.Developer.OAuth1Signer.RestSharpV2" Version="1.3.0" />
2828
</ItemGroup>
2929

30-
3130
</Project>

0 commit comments

Comments
 (0)