-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update To Support v5 API #48
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JakeQuilty I did what I could to CR it. Let me know if you have any questions.
@JakeQuilty Also make sure to update the wording of the "update to dev" commit since it seems really slim and un-useful |
3fa0bbe
to
32dabdd
Compare
The ListVariables method did not have the option to specify limit and offset parameters. The Resource method that parented it did have this parameter, and the original tests accounted for it. I also fixed the tests not accounting for an extra API call that the ListResources method makes.
This commit has an identical solution to the ListVariables. See the ListVariables commit for more details.
32dabdd
to
c8ad39f
Compare
163b7c0
to
244e44c
Compare
{ | ||
if (httpRequestTimeout == null) | ||
{ | ||
lock (locker) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it's the best pattern but we are locking a singleton so it looks good
@sashaCher - adding as a reviewer
{ | ||
string value = ConfigurationManager.AppSettings.Get(HTTP_REQUEST_TIMEOUT); | ||
httpRequestTimeout = 100000; //100 seconds; WebRequest default timeout | ||
if (!string.IsNullOrWhiteSpace(value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can extract a method that get values from configuration or use default and use it twice in thie class
Interlocked.Exchange(ref this.token, request.Read()); | ||
this.StartTokenTimer(new TimeSpan(0, 7, 30)); | ||
IntPtr bstr = IntPtr.Zero; | ||
byte[] bArr = new byte[credential.SecurePassword.Length]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add - cleaning secrets from memory footprint :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JakeQuilty Just a few more comments
@@ -0,0 +1,103 @@ | |||
// <copyright file="ApiConfigurationManager.cs" company="Conjur Inc."> | |||
// Copyright (c) 2016 Conjur Inc. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All files still need copyright section updated
{ | ||
if (httpRequestTimeout == null) | ||
{ | ||
lock (locker) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
II read some more on this - I think that due to this being an int, you can just mark it as volatile
instead of locking.
e09bb94
to
a120722
Compare
All cosmetic changes are done. The last commit is failing to build for the tests though |
@JakeQuilty / @uCatu Can we figure out how to get the current tests passing so that we can get this merged? |
Current errors:
|
@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 |
@izgeri the failures are with some tests already commented out. As far as I can tell, the project cannot build. |
@sgnn7 The origin of those error is C#7 syntax. |
@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. |
Fixed the failing build by reverting all the |
build.sh was failing to build due to different the code being updated with C#7 syntax instead of C#6. More detail [HERE](#48 (comment))
8853b17
to
785771f
Compare
build.sh was failing to build due to different the code being updated with C#7 syntax instead of C#6. This commit reverts those syntax changes. More detail #48 (comment)
785771f
to
ca74f0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed some nits but at this point we need to get this code into the repo and we can improve afterwards.
- README: - Removed old information - Added table of contents, required versions, contributing link - CONTRIBUTING: - Updated to follow community standards - Added some testing and dev info - CHANGELOG: - Added changes from #48 - Added links to older releases
- README: - Removed old information - Added table of contents, required versions, contributing link - CONTRIBUTING: - Updated to follow community standards - Added some testing and dev info - CHANGELOG: - Added changes from #48 - Added links to older releases
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
conjur list
)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
System.TypeLoadException
Functionality to Add