Skip to content
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

Custom Auth Query Params (2) #666

Merged
merged 7 commits into from Jan 30, 2016
Merged

Conversation

squid808
Copy link
Contributor

Picking up where pull 650 failed and left off prior to the big changes and my bad commits, this add the ability for users to include their own custom query parameters when making an authorization URL. This is in response to issue 638 at request of @peleyal.

By providing a KeyValuePair<string, string>[] for the UserDefinedQueryParams member of the GoogleAuthorizationCodeFlow.Initializer, this collection will be used to update the resulting url via Google.Apis.Requests.Parameters.ParameterUtils.IterateParameters().

An attempt at a unit test has been provided with /GoogleApis.Tests/Apis/Requests/Parameters/ParameterUtilsTest.cs

The initial build will fail due to the issue with the logger, which I'll detail via a note on the code line.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jan 20, 2016
@@ -29,6 +30,9 @@ namespace Google.Apis.Requests.Parameters
/// </summary>
public static class ParameterUtils
{
//TODO: Find out how to resolve the issue with setting up the Logger:
private static readonly ILogger Logger = ApplicationContext.Logger.ForType<ParameterUtils>();

This comment was marked as spam.

This comment was marked as spam.

@peleyal
Copy link
Collaborator

peleyal commented Jan 21, 2016

@squid808 I'm sorry that it takes me too long. I'll try to get to it before the weekend.
Sorry!
Eyal


/// <summary>Gets the user defined query parameters.</summary>
public IEnumerable<KeyValuePair<string, string>> UserDefinedQueryParams
{ get { return userDefinedQueryParams; } }

This comment was marked as spam.

@peleyal
Copy link
Collaborator

peleyal commented Jan 22, 2016

Awesome job, and thanks for moving from #650 to this one (huge merge.. sorry).
Looking forward for you to applying the comments and for us to push this change!
Enjoy the weekend, thanks!
Eyal

@squid808
Copy link
Contributor Author

@peleyal I updated things based on your comments, thank you. I had indeed not noticed your note in the previous PR to add a new constructor, so I sorted that all out. Using the other logger method also worked, thank you. However, since I'm still on VS 2013 something wonky is happening with the Page Streamer tests for me, which seems to have killed all my other unit tests, and now VS isn't even recognizing the tests to run them. So, I didn't get the test fully fixed just yet, but I wanted to throw the rest of the code up in the meantime. I'll update once I sort out the tests.

@squid808
Copy link
Contributor Author

Okey dokey, that should do it. I had the newer NUnit adapter installed for another project, and had disabled the older one in the VS extensions. I just had to enable both, didn't seem to be a conflict.

Also, fwiw I can only compile the solution if I comment out the PageStreamer tests. I haven't looked in to it too much, but I assume there is maybe some newer syntax that I can't compile in VS2013, so I've been commenting that whole file out and not committing that change as my workaround.

action(attribute.Type, name, value);
if (attribute.Type == RequestParameterType.UserDefinedQueries)
{
if (typeof(IEnumerable<KeyValuePair<string, string>>).IsAssignableFrom(value.GetType()))

This comment was marked as spam.

@peleyal
Copy link
Collaborator

peleyal commented Jan 25, 2016

Awesome work!
Note my two small comments to this PR.
After addressing them, feel free to change to remove DO NOT MERGE from your PR.

Thanks for adding this functionality and being patient with my slow review.
Eyal

…RequestParameterAttribute, updated ParameterUtilsTests
}

[Test]
public void RevokeTokenAsyncTest()

This comment was marked as spam.

This comment was marked as spam.

@peleyal
Copy link
Collaborator

peleyal commented Jan 27, 2016

So, like I mentioned my bad about the change to Attribute. Like I explained you should actually revert it.

Regarding the broken tests, you can actually not test the Revoke method in this PR and just add a TODO to test it later on. We will focus only on your change here, and later on in another PR we will test more methods.

Thanks!
Eyal

…code accordingly, added test assertion to reflect changes
@squid808
Copy link
Contributor Author

I think that should about cover it. If you want me to add more info or a person's name in the TODO for the test, I certainly can. Once I confirm the build finishes (and that I didn't do anything stupid), I'll remove the DO NOT MERGE from the PR name.

@squid808 squid808 changed the title Custom Auth Query Params (2) - DO NOT MERGE Custom Auth Query Params (2) Jan 28, 2016
/// by the library which will be included in the resultant authentication URL.
/// </summary>
/// <remarks>
/// The name of this parameter is used only for the constructor and will not end up in the resultant query string.

This comment was marked as spam.

Assert.That(result, Contains.Substring("customParam2=customVal2"));

//assert that the parameter name for the custom parameters does not carry through to the result
Assert.IsFalse(result.Contains("query_param_attribute_name"));

This comment was marked as spam.

@peleyal
Copy link
Collaborator

peleyal commented Jan 29, 2016

We are really close!
I just have small nits (just comments), thanks for being so patient.
Eyal

@squid808
Copy link
Contributor Author

Glad for the nits, sorry there were so many that were simply catchable. I'm running on fumes lately. I think that should square it all away.

@peleyal
Copy link
Collaborator

peleyal commented Jan 29, 2016

Awesome! I'll wait for all the tests to pass, and then I'll merge it. Thanks so much for implementing it.
Eyal

peleyal added a commit that referenced this pull request Jan 30, 2016
@peleyal peleyal merged commit ab2161a into googleapis:master Jan 30, 2016
@peleyal
Copy link
Collaborator

peleyal commented Jan 30, 2016

@squid808, well done! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants