cyberark / conjur-api-dotnet

.NET client for the CyberArk Conjur API
Apache License 2.0
15 stars 11 forks source link

Update To Support v5 API #48

Closed JakeQuilty closed 4 years ago

JakeQuilty commented 4 years ago

This PR updates the .NET API to support the v5 API.

Functionality Added

These methods were tested to make sure they support the v5 API. More details

Methods

Client

Client Client(uri, account)

LogIn(string userName, string password)

TrustedCertificates.ImportPem (string certPath)

<Client>.Credential = new NetworkCredential(string userName, string apiKey)

IEnumerable<Variable> ListVariables(string query = null)

uint CountVariables(string query = null)

Host CreateHost(string name, string hostFactoryToken)

Policy

Policy <Client>.Policy(string policyName)

policy.LoadPolicy(Stream policyContent)

Variable

Variable <Client>.Variable(string name)

Boolean Check(string privilege)

AddSecret(string val)

String GetValue()

Tests Fixed

api-dotnet.test.Conjur.Test.VariablesTest.GetVariableTest

api-dotnet.test.Conjur.Test.UserTest.ListUserTest api-dotnet.test.Conjur.Test.VariablesTest.ListVariableTest

api-dotnet.test.Conjur.Test.ClientTest.ActingAsTest

Outstanding Work

Tests to Fix

api-dotnet.test.Conjur.Test.AuthenticatorTest.TestTokenCaching api-dotnet.test.Conjur.Test.AuthenticatorTest.TestTokenThreadSafe api-dotnet.test.Conjur.Test.ClientTest.TestLogin

api-dotnet.test.Conjur.Test.HostFactoryTest.TestCreateHost api-dotnet.test.Conjur.Test.ResourceTest.TestCheck

Functionality to Add

sgnn7 commented 4 years ago

@JakeQuilty Also make sure to update the wording of the "update to dev" commit since it seems really slim and un-useful

JakeQuilty commented 4 years ago

@uCatu can you take a look at some of @sgnn7 's suggestions to your commit?

JakeQuilty commented 4 years ago

All cosmetic changes are done. The last commit is failing to build for the tests though

sgnn7 commented 4 years ago

@JakeQuilty / @uCatu Can we figure out how to get the current tests passing so that we can get this merged?

sgnn7 commented 4 years ago

Current errors:

[2020-05-22T17:11:00.545Z] /build/conjur-api/conjur-api.csproj (default targets) ->
[2020-05-22T17:11:00.545Z] /usr/lib/mono/4.5/Microsoft.CSharp.targets (CoreCompile target) ->
[2020-05-22T17:11:00.545Z] 
[2020-05-22T17:11:00.545Z]  Client.cs(66,16): error CS1043: Invalid accessor body `=>', expecting `;' or `{'
[2020-05-22T17:11:00.545Z]  Client.cs(66,45): error CS1014: A get or set accessor expected
[2020-05-22T17:11:00.545Z]  ApiConfigurationManager.cs(49,16): error CS1043: Invalid accessor body `=>', expecting `;' or `{'
[2020-05-22T17:11:00.545Z]  ApiConfigurationManager.cs(73,16): error CS1043: Invalid accessor body `=>', expecting `;' or `{'
[2020-05-22T17:11:00.545Z] 
[2020-05-22T17:11:00.545Z]   0 Warning(s)
[2020-05-22T17:11:00.545Z]   4 Error(s)
izgeri commented 4 years ago

@sgnn7 @JakeQuilty is this even with some of the tests commented out, to be updated in follow-up issues? or are we not commenting out any test cases anymore?

I am ok with commenting some test cases and fixing them in follow-up issues, as long as we log the issues for them and reference them here

sgnn7 commented 4 years ago

@izgeri the failures are with some tests already commented out. As far as I can tell, the project cannot build.

sashaCher commented 4 years ago

@sgnn7 The origin of those error is C#7 syntax. In our environment we are building the SDK with up to date msbuild toolset so we even haven't pay an attention to this. You can read more about syntax and versions there. You can "rephrase" those code segments using C#6 or lower convention or to upgrade mono compiler. It looks that it supports "Expression-bodied constructors, finalizers and accessors".

sgnn7 commented 4 years ago

@sashaCher Thanks for the explanation - makes sense! It may be useful to use the old syntax until we figure out what the bottom version for this API should be though but feel free to update the test runner instead if C#6 is end-of-life already.

JakeQuilty commented 4 years ago

Fixed the failing build by reverting all the get and set with => back to curly brackets