summaryrefslogtreecommitdiff
path: root/spec/unit/knife/bootstrap_spec.rb
Commit message (Collapse)AuthorAgeFilesLines
* Remove unused codeVivek Singh2020-07-211-1/+0
| | | | Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* Fix test casesVivek Singh2020-07-211-5/+2
| | | | Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* More aggressively deprecate config_valueLamont Granquist2020-06-221-0/+1
| | | | | | | | | | | | | | | Force subclasses to use the `config` hash directly. This should not affect any knife plugins shipping in chef-workstation since the calls to config_value have already been removed from all of those plugins. The multiple-argument version of config_value was not actually used anywhere in those plugins and the single value version was removed and replaced with accessing the config hash. Since that was introduced sometime in 15.x when the bootstrap changes went in, it is not expected that many external knife plugins have picked up the usage of config_value. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Warn during bootstrapping when using validation keyswarn_on_validator_bootstrapTim Smith2020-06-091-2/+2
| | | | | | | | | | | | | We should highly encourage users to move to validatorless bootstrapping 1) It's more secure 2) It requires less admin work since there no validation key to pass around or rotate This also provides an improved message helping the user to move off the old keys and fixes some bad formatting where the 2nd line was indented about 40 columns. Signed-off-by: Tim Smith <tsmith@chef.io>
* Knife bootstrap options cleanupLamont Granquist2020-04-171-44/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have issue that are caused by old code before merging of hash values were done correctly. The `config` hash correctly merges all options and should always be used. Knife plugins should never touch Chef::Config[:knife] values (either reading or writing from them). The `knife_config` should be converted to the `config` hash since it directly accesses Chef::Config[:knife] values. The `config_value()` helper should no longer be used. Very clearly most people started to use that when they should just use the config hash directly. That was intended to be used only when a knife cli option was being renamed and the former configuration value needed to be used as well. It has been cargo culted around as the way to access config values, and that should really stop. The DataBagSecretOption mixin has been cleaned up so that the cli options read+write only to the config[:cl_secret] and config[:cl_secret_file] values. The config file values go into config[:secret] and config[:secret_file]. The fact that those are the merged values in the `config` hash doesn't matter since only the cli should be writing to the first two and only the config file should be writing to the latter two. I don't know why it was made so complicated to begin with, but if there's some hidden chef-11.early backcompat there, then chef-16 deliberately breaks that. The use of `locate_config_value` helpers in all knife plugins is also discouraged (but they all implement those themselves), just use the config hash, which has the correct hash merge ordering. All of those need to be deleted. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Remove copyright dateslcg/remove-copyright-datesLamont Granquist2020-04-131-1/+1
| | | | | | | | Legally incredibly dubious, particularly since we don't follow it strictly as policy, and we have git history instead, which does it right. This is just a waste of time and a cargo cult. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* some spec typosVivek Singh2020-04-071-1/+1
| | | | Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* Fix failing specsVivek Singh2020-01-241-1/+1
| | | | Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* Merge pull request #8856 from MsysTechnologiesllc/bootstrap_password_promptTim Smith2019-10-081-10/+46
|\ | | | | Fix Bootstrap password prompt
| * Fixed test-case for password prompt.Amol Shinde2019-09-111-2/+2
| | | | | | | | Signed-off-by: Amol Shinde <amol.shinde@msystechnologies.com>
| * Fix password prompt in the bootstrap command.Amol Shinde2019-09-111-10/+46
| | | | | | | | | | | | - Fix test-case for password prompt. Signed-off-by: Amol Shinde <amol.shinde@msystechnologies.com>
* | Replace exception text check with reason symbolVivek Singh2019-08-291-1/+1
| | | | | | | | Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* | Add test case to ensure pty requestedVivek Singh2019-08-201-0/+13
| | | | | | | | Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* | Bootstrap: Set pty true only if requiredVivek Singh2019-08-141-5/+0
|/ | | | | | | - rescue the exception and retry with pty: true if host configured with `requiretty`. - Remove the default pty: true for all node that causes the error in the window and other hosts while detecting the system. Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* fix 4 copsLamont Granquist2019-07-051-4/+10
| | | | | | | | | | | | | | - Layout/MultilineMethodCallBraceLayout - Layout/ClosingParenthesisIndentation - Layout/IndentFirstArgument EnforcedStyle: consistent - Layout/BlockEndNewline the first of these autocorrected to horrible looking code which exposed that we really needed the other three as well, which also cleaned up a bunch of other terrible looking code. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/RegexpLiteralLamont Granquist2019-07-051-10/+10
| | | | | | | given how many regexps we have with /'s in the match this seems like a very good one. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Layout/AlignArgumentslcg/new-chefstyleLamont Granquist2019-07-021-3/+3
| | | | | | | | | | | | | | this is using: Layout/AlignArguments: Enabled: true EnforcedStyle: with_fixed_indentation the default style can use really excessive whitespace. on starting lines which are already long, it fully indents across to where the arguments start and then begins the line there. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* use mixlib-cli's deprecation mechanismMarc A. Paradise2019-06-101-101/+0
| | | | | | | | Deprecation logic is now available in `mixlib-cli` via `deprecated_option`. Let's use that instead of keeping our custom deprecation behavior. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* Chef-15: Adding short argument's deprecation check (#8626)Nimesh2019-06-051-11/+79
| | | | | | | | | - Handles "-x" that was used to set "winrm-user" and is now Deprecated. - Using symmetrical "USERNAME" and "PASSWORD" verbiages while displaying deprecated warnings. - Added test cases - Ensured Chefstyle - Fixes MSYS-1046 Signed-off-by: Nimesh-Msys <nimesh.patni@msystechnologies.com>
* Fix ssh user set from cli (#8558)dheerajd-msys2019-05-281-4/+4
| | | Signed-off-by: dheerajd-msys <dheeraj.dubey@msystechnologies.com>
* fix order of connection before register node (#8574)dheerajd-msys2019-05-241-1/+1
| | | Signed-off-by: dheerajd-msys <dheeraj.dubey@msystechnologies.com>
* Only set client_pem in bootstrap_context when validatorlessbtm/client_key_validator_fixBryan McLellan2019-05-171-5/+8
| | | | | | | | | We should only set bootstrap_context.client_pem if we're a validatorless bootstrap. Fixes #8534 Signed-off-by: Bryan McLellan <btm@loftninjas.org>
* Enable pty for bootstrap sshbootstrap-uses-ptyMarc A. Paradise2019-05-161-14/+23
| | | | | | | | This will allow bootstrap to work with systems that have `requiretty` configured, and is consistent with the behavior of Chef 14 bootstrap Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* Bootstrap updatesmp/bootstrap-updatesMarc A. Paradise2019-05-141-12/+41
| | | | | | | | | | | | | | | | | | | This includes a few fixes: 1. properly handle the default value for session_timeout in cases where merge_config is not called (plugins) to populate defaults. 2. verify that we're using the ssh protoocl before referencing ssh constants. 3. capture and compare the higher-level Train::Error for the check to see if we've gotten a missing fingerprint error, instead of using Train::Transports::SSHFailed which may not be loaded when exception is being evaluated. 4. Add tests for missing fingerprint behavior 5. do not save session_timeout to Chef::Config[:knife], it was not referenced as knife config in any location and we're trying to move away from pushing CLI values into knife config. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* Merge pull request #8521 from ↵Bryan McLellan2019-05-131-7/+56
|\ | | | | | | | | MsysTechnologiesllc/VSingh/bootstrap-session-timeout Chef 15: Add --session-timeout bootstrap option for both ssh & winrm
| * Add a warning when session-timeout is too shortMarc A. Paradise2019-05-131-2/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We converted --winrm-session-timeout MINUTES to --session-timeout SECONDS If someone is providing a short session timeout, it's possible that they're doing so based on the flag accepting minutes. We'll warn them and suggest an alternative so that if things go wrong, they'll know where to start looking. We can remove this once we remove the deprecation for winrm-session-timeout Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
| * Ensure tests are aware of CLI default valuesMarc A. Paradise2019-05-131-3/+7
| | | | | | | | | | | | | | We added default value for session-timeout, but the tests weren't aware of that because config was mocked. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
| * Minor fixes related to chefstyleVivek Singh2019-05-131-1/+1
| | | | | | | | Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
| * Add --session-timeout bootstrap option for both ssh & winrmVivek Singh2019-05-131-4/+26
| | | | | | | | | | | | | | | | | | - Add bootstrap option --session-timeout. - Add wirnrm-session to deprecations. - Default --session-timeout value is 60 secs(same was added for --winrm-session-timeout). - Modify existing specs related to old winrm session timeout key and add specs for session timeout. Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* | move retry into #connect!Bryan McLellan2019-05-131-1/+1
| | | | | | | | Signed-off-by: Bryan McLellan <btm@loftninjas.org>
* | Use new Net:SSH host key verify valuesBryan McLellan2019-05-131-2/+2
|/ | | | | | | | | | | | | Fixes #8482 by prompting to continue if the host key is not recognized. This attempts to tell Net:SSH to accept and write the key but it is only temporarily accepting. This changes the parameters of --ssh-verify-host-key (which is new) to take the Net::SSH values, which get passed through by train. This allows the user more options than only verifying or not. Signed-off-by: Bryan McLellan <btm@loftninjas.org>
* Use exports compatibile with /bin/sh in the bootstrap scriptmarkgibbons2019-05-081-0/+22
| | | | | | | | | The bootstrap script is explicitly using /bin/sh. On some solaris servers the version of /bin/sh exporting environment variables using "export id=value" fails. The form "id=value export id" does work. Bootstrap fails when the wrong form is used. Signed-off-by: markgibbons <mark.gibbons@nordstrom.com>
* knife bootstrap should only request license when installing Chef 15knife_licensetyler-ball2019-05-071-5/+28
| | | | | | | | Also updating the transmission of the license acceptance through the config.rb because that brings it in line with existing patterns (Test Kitchen). Signed-off-by: tyler-ball <tball@chef.io>
* Remove purposefully failing test - no longer want to gate releasestyler-ball2019-05-071-4/+0
| | | | Signed-off-by: tyler-ball <tball@chef.io>
* Merge pull request #8354 from chef/license_acceptanceTyler Ball2019-05-061-0/+11
|\ | | | | Add logic to require acceptannce of the Chef license to run the client
| * Purposefully adding a failing test to prevent Chef Infra from promoting ↵license_acceptancetyler-ball2019-05-031-0/+4
| | | | | | | | | | | | unstable -> current Signed-off-by: tyler-ball <tball@chef.io>
| * Adding license acceptance support to 'knife bootstrap'tyler-ball2019-05-031-5/+7
| | | | | | | | Signed-off-by: tyler-ball <tball@chef.io>
| * knife bootstrap is only knife command to have license acceptance flowtyler-ball2019-05-031-0/+5
| | | | | | | | | | | | | | | | Because in order to run `chef-client` on the bootstrapped node the user needs to have accepted the licenses locally. Right now we have commented out this code because we will enforce it in a different PR. Signed-off-by: tyler-ball <tball@chef.io>
* | `prerelease` -> `channel` in bootstrap contextsMarc A. Paradise2019-05-031-9/+1
| | | | | | | | | | | | | | | | | | | | | | | | Updates BootstrapContext and WindowsBootstrapContext to expect a 'channel' config value instead of a 'prelease' value. This removes the old behavior of inferring pre-release (current) from the presence of a fourth version number in the version string (eg 1.2.3.pre) - that was specific to gem installs, and gem installs are not used in bootstrap. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* | Change 'prerelease' to 'channel'.Marc A. Paradise2019-05-031-1/+11
|/ | | | | | | | | | | | | This adds support for deprecating a boolean flag into a non-boolean value, and uses it to make `--prerelease` deprecated in favor of `--channel current`. By default, `channel` is `stable`. Separately, all deprecated options are now configured to display at the end of the options list, instead of mixed into the non-deprecated list. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* Require 'net/ssh' before we reference it.Marc A. Paradise2019-05-021-4/+8
| | | | | | | | | This also updates bootstrap to provide `non_interactive` as an option to TrainConnector, instead of TrainConnector setting it behind the scenes. Bootstrap uses non-interactive to ensure that we don't get net/ssh prompts for password in case of password failure. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* Fix incorrect deprecation warningsmp/bootstrap-deprecation-fixesMarc A. Paradise2019-05-011-7/+7
| | | | | | | | | | | | | | Fixed incorrect option mapping where deprecated flags would have a 'long' taken from the replacement flag. Updated the behavior in case of conflicting flags (for example --ssh-user and --connection-user) to avoid surprising results by failing with an error instead of trying to resolve intent. Renamed things a bit for readability/consistency. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* Switch bootstrap to use TrainConnector.Marc A. Paradise2019-04-291-40/+43
| | | | | | This replaces TargetHost, and the associated renames/minor updates. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* Use an empty dir for certs test instead of trying to mock oneMarc A. Paradise2019-04-241-4/+6
| | | | | | | | | When no certs are available, test with an actual empty certs dir. This works around a problem with the mock where on the Windows platform, a buried call to Dir.glob is returning the actual certificates directory content instead of the empty list required for the test. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* test fixMarc A. Paradise2019-04-241-2/+2
| | | | Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* Relax the match for validation key pathMarc A. Paradise2019-04-241-2/+2
| | | | | | | | Because we expand the path to the validation key, the exact match of "/blah" under Windows was failing, because it expanded to "C:/blah" Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* RubocopMarc A. Paradise2019-04-241-1/+0
| | | | Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* Make deprecations more robustMarc A. Paradise2019-04-241-11/+11
| | | | | | | | | | | THis improves deprecation handling by not trying to infer old opts/long string, and correctly handles setting the boolean flag on deprecated options. This also fixes references to :password to be in line with the option name, :connection_password. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* deprecate old version of changed CLI flags.Marc A. Paradise2019-04-241-0/+33
| | | | | | | | This adds a lightweight deprecation mechanism in order to warn the human that they're using deprecated flags, and to continue to allow Bootstrap to work even if that happens. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* Rubocop!Marc A. Paradise2019-04-241-136/+124
| | | | Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>