Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Fix deploy using client-id and client-secret #2820

Merged
merged 2 commits into from
May 2, 2018
Merged

Fix deploy using client-id and client-secret #2820

merged 2 commits into from
May 2, 2018

Conversation

maniSbindra
Copy link
Contributor

@maniSbindra maniSbindra commented May 1, 2018

What this PR does / why we need it: Fix Issue #2657

Which issue this PR fixes (optional, in fixes #2657 format, will close that issue when PR gets merged): fixes #2657 #2657

Special notes for your reviewer:

  • Added condition to check if Client Id and Secret are specified in the deployment command
  • Added tests to cover conditions when Client Id and Client secret are provided in the deployment command, and when id and secret are not specified in either the api model or deployment command

If applicable:

  • documentation
  • unit tests
  • tested backward compatibility (ie. deploy with previous version, upgrade with this branch)

Release note:

@ghost ghost assigned maniSbindra May 1, 2018
@ghost ghost added the in progress label May 1, 2018
@CecileRobertMichon CecileRobertMichon changed the title changes to fix issue 2657, including more tests Fix deploy using client-id and client-secret May 1, 2018
Copy link
Contributor

@CecileRobertMichon CecileRobertMichon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm found some changes to make on second review, see below

cmd/deploy.go Outdated
@@ -241,6 +241,11 @@ func autofillApimodel(dc *deployCmd) {
Secret: secret,
ObjectID: servicePrincipalObjectID,
}
} else if dc.containerService.Properties.ServicePrincipalProfile == nil && dc.ClientID.String() != "" && dc.ClientSecret != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about the case where dc.containerService.Properties.ServicePrincipalProfile is not nil but is empty? For example, "servicePrincipalProfile": { "clientId": "", "secret": "" }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to address this case since it applies to most example json apimodel in the examples/ folder

@@ -40,6 +41,19 @@ const ExampleAPIModelWithDNSPrefix = `{
}
`

const ExampleAPIModelWithoutServicePrincipalProfile = `{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add a test case for empty ServicePrincipalProfile

Copy link
Contributor Author

@maniSbindra maniSbindra May 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CecileRobertMichon A couple of questions

  1. just wanted to double check the expected result.
    If ServicePrincipalProfile is Empty, and no client id and secret specified in deployment command (--client-id , --client-secret) then expected result should be
  • deployCmd.containerService.Properties.ServicePrincipalProfile.ClientID == ""
  • deployCmd.containerService.Properties.ServicePrincipalProfile.Secret == ""
    ?
  1. If ServicePrincipalProfile is Empty, and client id and secret are specified in deployment command (--client-id , --client-secret) then should the code use the client-id and client-secret in the deployment command? This second part will need modification to code as well as new test cases. If this is to be implemented perhaps it would make more sense to have a separate new issue

Copy link
Contributor

@CecileRobertMichon CecileRobertMichon May 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. That's correct
  2. Yes, exactly. It shouldn't be very complicated to add to this PR. I believe all you need to do is to change your if statement in deploy.go to } else if (dc.containerService.Properties.ServicePrincipalProfile == nil || (dc.containerService.Properties.ServicePrincipalProfile.ClientID == "" && dc.containerService.Properties.ServicePrincipalProfile.Secret == "") ) && dc.ClientID.String() != "" && dc.ClientSecret != "" and add the appropriate unit test case. We just want to make sure that the change you made applies if the sp profile is declared but contains no ID and secret values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Makes sense. So test cases for conditions where id and secret are specified in both the api model and deployment command can be taken up later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CecileRobertMichon i have made the requested changes, please review and let me know if any further changes are needed

@codecov
Copy link

codecov bot commented May 2, 2018

Codecov Report

Merging #2820 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2820      +/-   ##
==========================================
+ Coverage   46.94%   46.94%   +<.01%     
==========================================
  Files          86       86              
  Lines       12809    12813       +4     
==========================================
+ Hits         6013     6015       +2     
- Misses       6241     6242       +1     
- Partials      555      556       +1
Impacted Files Coverage Δ
cmd/deploy.go 25.58% <100%> (+1.77%) ⬆️
pkg/operations/kubernetesupgrade/upgrader.go 56.66% <0%> (-0.84%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8123237...e53d3d4. Read the comment docs.

Copy link
Contributor

@CecileRobertMichon CecileRobertMichon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deploy using client-id and client-secret command line switches throws an error
2 participants