hammer_cli_foreman 0.18.2 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/foreman.yml +20 -0
- data/doc/host_create.md +19 -10
- data/doc/release_notes.md +12 -4
- data/lib/hammer_cli_foreman/api/authenticator.rb +81 -0
- data/lib/hammer_cli_foreman/api/connection.rb +48 -33
- data/lib/hammer_cli_foreman/api/interactive_basic_auth.rb +2 -2
- data/lib/hammer_cli_foreman/api/oauth/authentication_code_grant.rb +100 -0
- data/lib/hammer_cli_foreman/api/oauth/password_grant.rb +81 -0
- data/lib/hammer_cli_foreman/api/session_authenticator_wrapper.rb +34 -80
- data/lib/hammer_cli_foreman/auth.rb +54 -20
- data/lib/hammer_cli_foreman/authenticate/login.rb +21 -0
- data/lib/hammer_cli_foreman/command_extensions/hosts/help/compute_resources.rb +1 -0
- data/lib/hammer_cli_foreman/command_extensions/ping.rb +14 -0
- data/lib/hammer_cli_foreman/command_extensions/status.rb +44 -0
- data/lib/hammer_cli_foreman/command_extensions.rb +2 -0
- data/lib/hammer_cli_foreman/commands.rb +1 -1
- data/lib/hammer_cli_foreman/compute_attribute.rb +22 -5
- data/lib/hammer_cli_foreman/compute_resource/base.rb +1 -1
- data/lib/hammer_cli_foreman/compute_resource/ec2.rb +1 -1
- data/lib/hammer_cli_foreman/compute_resource/gce.rb +1 -1
- data/lib/hammer_cli_foreman/compute_resource/libvirt.rb +11 -8
- data/lib/hammer_cli_foreman/compute_resource/openstack.rb +1 -1
- data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +7 -4
- data/lib/hammer_cli_foreman/compute_resource/rackspace.rb +1 -1
- data/lib/hammer_cli_foreman/compute_resource/vmware.rb +6 -6
- data/lib/hammer_cli_foreman/hosts/common_update_options.rb +1 -1
- data/lib/hammer_cli_foreman/location.rb +1 -1
- data/lib/hammer_cli_foreman/openid_connect.rb +68 -0
- data/lib/hammer_cli_foreman/organization.rb +1 -1
- data/lib/hammer_cli_foreman/output/formatters.rb +4 -5
- data/lib/hammer_cli_foreman/partition_table.rb +1 -0
- data/lib/hammer_cli_foreman/ping.rb +24 -0
- data/lib/hammer_cli_foreman/report_template.rb +3 -2
- data/lib/hammer_cli_foreman/sessions.rb +92 -0
- data/lib/hammer_cli_foreman/status.rb +53 -0
- data/lib/hammer_cli_foreman/subnet.rb +1 -0
- data/lib/hammer_cli_foreman/template.rb +1 -0
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/lib/hammer_cli_foreman.rb +8 -0
- data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/test/data/1.24/foreman_api.json +1 -0
- data/test/data/README.md +2 -2
- data/test/functional/commands/list_test.rb +2 -2
- data/test/functional/host_test.rb +0 -20
- data/test/functional/ping_test.rb +34 -0
- data/test/functional/status_test.rb +46 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-CreateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-InfoCommand-output.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-ListCommand-output.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-DeleteCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-ListCommand-output.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-SetCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-SetCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-CreateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-InfoCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-ListCommand-output.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-CreateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-DeleteParameterCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-DeleteParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-InfoCommand-output.xml +21 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-ListCommand-output.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-SetParameterCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-SetParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-CreateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-InfoCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-ListCommand-output.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Environment.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-ExceptionHandler.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Host-CreateCommand-parameters.xml +46 -0
- data/test/reports/TEST-HammerCLIForeman-Host-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Host-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-DeleteParameterCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Host-DeleteParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-InfoCommand-output.xml +85 -0
- data/test/reports/TEST-HammerCLIForeman-Host-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Host-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-ListCommand-output.xml +21 -0
- data/test/reports/TEST-HammerCLIForeman-Host-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Host-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-PuppetRunCommand-output.xml +9 -0
- data/test/reports/TEST-HammerCLIForeman-Host-PuppetRunCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-SetParameterCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Host-SetParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-StatusCommand-output.xml +9 -0
- data/test/reports/TEST-HammerCLIForeman-Host-StatusCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-UpdateCommand-parameters.xml +40 -0
- data/test/reports/TEST-HammerCLIForeman-Host-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-CreateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteParameterCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-InfoCommand-output.xml +29 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-InfoCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-ListCommand-output.xml +27 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-SetParameterCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-SetParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-UpdateCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Location-CreateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Location-CreateCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Location-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Location-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Location-DeleteCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Location-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Location-ListCommand-output.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Location-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Location-ListCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Location-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Location-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Location-UpdateCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Location-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Location.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-CreateCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-InfoCommand-output.xml +23 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-ListCommand-output.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-UpdateCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Medium.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-CreateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteParameterCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-InfoCommand-output.xml +27 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-ListCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-SetParameterCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-SetParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-UpdateCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-CreateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-CreateCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-DeleteCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand-output.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-UpdateCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Organization.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-CreateCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-DumpCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-DumpCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-InfoCommand-output.xml +19 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-ListCommand-output.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-UpdateCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-CreateCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-InfoCommand-output.xml +21 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-ListCommand-output.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-ListCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-CreateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-InfoCommand-output.xml +43 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-ListCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template-CreateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Template-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template-DeleteCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Template-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template-DumpCommand-parameters.xml +12 -0
- data/test/reports/TEST-HammerCLIForeman-Template-DumpCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template-InfoCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Template-InfoCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Template-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template-ListCommand-output.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Template-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Template-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template-ListKindsCommand-parameters.xml +9 -0
- data/test/reports/TEST-HammerCLIForeman-Template-ListKindsCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template-UpdateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Template-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-User-CreateCommand-parameters.xml +19 -0
- data/test/reports/TEST-HammerCLIForeman-User-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-User-DeleteCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-User-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-User-InfoCommand-output.xml +23 -0
- data/test/reports/TEST-HammerCLIForeman-User-InfoCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-User-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-User-ListCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-User-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-User-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-User-UpdateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-User-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-User.xml +7 -0
- data/test/reports/TEST-MiniTest-Spec.xml +7 -0
- data/test/test_helper.rb +1 -1
- data/test/unit/api/interactive_basic_auth_test.rb +1 -1
- data/test/unit/api/oauth/oauth_authentication_code_grant_test.rb +88 -0
- data/test/unit/api/oauth/oauth_password_grant_test.rb +92 -0
- data/test/unit/api/session_authenticator_wrapper_test.rb +85 -70
- data/test/unit/sessions_test.rb +199 -0
- metadata +600 -81
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite name="HammerCLIForeman::Template::DeleteCommand::parameters" tests="2" time="0.006023587" failures="0" errors="0" skipped="0" assertions="2">
|
3
|
+
<testcase name="test_0001_should accept id" time="0.003387934" assertions="1">
|
4
|
+
</testcase>
|
5
|
+
<testcase name="test_0002_should fail with id missing" time="0.002288163" assertions="1">
|
6
|
+
</testcase>
|
7
|
+
<system-out>
|
8
|
+
</system-out>
|
9
|
+
<system-err>
|
10
|
+
</system-err>
|
11
|
+
</testsuite>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite name="HammerCLIForeman::Template::DumpCommand::parameters" tests="2" time="0.006551534" failures="0" errors="0" skipped="0" assertions="2">
|
3
|
+
<testcase name="test_0002_should fail with id missing" time="0.002681467" assertions="1">
|
4
|
+
</testcase>
|
5
|
+
<testcase name="test_0001_should accept id" time="0.00348684" assertions="1">
|
6
|
+
</testcase>
|
7
|
+
<system-out>
|
8
|
+
|
9
|
+
</system-out>
|
10
|
+
<system-err>
|
11
|
+
</system-err>
|
12
|
+
</testsuite>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite name="HammerCLIForeman::Template::InfoCommand::output" tests="5" time="0.05174111" failures="0" errors="0" skipped="0" assertions="9">
|
3
|
+
<testcase name="test_0001_should print 1 records" time="0.037660149" assertions="1">
|
4
|
+
</testcase>
|
5
|
+
<testcase name="test_0002_should print column Id" time="0.003793605" assertions="2">
|
6
|
+
</testcase>
|
7
|
+
<testcase name="test_0004_should print column Type" time="0.003832859" assertions="2">
|
8
|
+
</testcase>
|
9
|
+
<testcase name="test_0003_should print column Name" time="0.003094357" assertions="2">
|
10
|
+
</testcase>
|
11
|
+
<testcase name="test_0005_should print column OS ids" time="0.002979744" assertions="2">
|
12
|
+
</testcase>
|
13
|
+
<system-out>
|
14
|
+
</system-out>
|
15
|
+
<system-err>
|
16
|
+
</system-err>
|
17
|
+
</testsuite>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite name="HammerCLIForeman::Template::InfoCommand::parameters" tests="2" time="0.006037102" failures="0" errors="0" skipped="0" assertions="2">
|
3
|
+
<testcase name="test_0002_should fail with no arguments" time="0.002598291" assertions="1">
|
4
|
+
</testcase>
|
5
|
+
<testcase name="test_0001_should accept id" time="0.002923084" assertions="1">
|
6
|
+
</testcase>
|
7
|
+
<system-out>
|
8
|
+
</system-out>
|
9
|
+
<system-err>
|
10
|
+
</system-err>
|
11
|
+
</testsuite>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite name="HammerCLIForeman::Template::ListCommand::output" tests="4" time="0.013628268" failures="0" errors="0" skipped="0" assertions="7">
|
3
|
+
<testcase name="test_0001_should print records" time="0.004316278" assertions="1">
|
4
|
+
</testcase>
|
5
|
+
<testcase name="test_0004_should print column Type" time="0.003352769" assertions="2">
|
6
|
+
</testcase>
|
7
|
+
<testcase name="test_0002_should print column Id" time="0.002863547" assertions="2">
|
8
|
+
</testcase>
|
9
|
+
<testcase name="test_0003_should print column Name" time="0.002747881" assertions="2">
|
10
|
+
</testcase>
|
11
|
+
<system-out>
|
12
|
+
</system-out>
|
13
|
+
<system-err>
|
14
|
+
</system-err>
|
15
|
+
</testsuite>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite name="HammerCLIForeman::Template::ListCommand::parameters" tests="5" time="0.01275035" failures="0" errors="0" skipped="0" assertions="5">
|
3
|
+
<testcase name="test_0001_should accept no arguments" time="0.002829972" assertions="1">
|
4
|
+
</testcase>
|
5
|
+
<testcase name="test_0002_should accept search" time="0.002381625" assertions="1">
|
6
|
+
</testcase>
|
7
|
+
<testcase name="test_0004_should accept page" time="0.002272882" assertions="1">
|
8
|
+
</testcase>
|
9
|
+
<testcase name="test_0005_should accept order" time="0.002327916" assertions="1">
|
10
|
+
</testcase>
|
11
|
+
<testcase name="test_0003_should accept per page" time="0.002395138" assertions="1">
|
12
|
+
</testcase>
|
13
|
+
<system-out>
|
14
|
+
</system-out>
|
15
|
+
<system-err>
|
16
|
+
</system-err>
|
17
|
+
</testsuite>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite name="HammerCLIForeman::Template::ListKindsCommand::parameters" tests="1" time="0.002669237" failures="0" errors="0" skipped="0" assertions="1">
|
3
|
+
<testcase name="test_0001_should accept no arguments" time="0.0023816" assertions="1">
|
4
|
+
</testcase>
|
5
|
+
<system-out>
|
6
|
+
</system-out>
|
7
|
+
<system-err>
|
8
|
+
</system-err>
|
9
|
+
</testsuite>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite name="HammerCLIForeman::Template::UpdateCommand::parameters" tests="2" time="0.006998183" failures="0" errors="0" skipped="0" assertions="2">
|
3
|
+
<testcase name="test_0002_should fail with id missing" time="0.00309061" assertions="1">
|
4
|
+
</testcase>
|
5
|
+
<testcase name="test_0001_should accept id, name, file, type, audit comment, os ids" time="0.003626329" assertions="1">
|
6
|
+
</testcase>
|
7
|
+
<system-out>
|
8
|
+
</system-out>
|
9
|
+
<system-err>
|
10
|
+
</system-err>
|
11
|
+
</testsuite>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite name="HammerCLIForeman::User::CreateCommand::parameters" tests="6" time="0.070330632" failures="0" errors="0" skipped="0" assertions="6">
|
3
|
+
<testcase name="test_0005_should fail with password missing" time="0.001987686" assertions="1">
|
4
|
+
</testcase>
|
5
|
+
<testcase name="test_0001_should accept all required" time="0.026994394" assertions="1">
|
6
|
+
</testcase>
|
7
|
+
<testcase name="test_0004_should fail with mail missing" time="0.001736479" assertions="1">
|
8
|
+
</testcase>
|
9
|
+
<testcase name="test_0003_should fail with login missing" time="0.001538005" assertions="1">
|
10
|
+
</testcase>
|
11
|
+
<testcase name="test_0002_should accept all required plus names" time="0.035799589" assertions="1">
|
12
|
+
</testcase>
|
13
|
+
<testcase name="test_0006_should fail with auth source missing" time="0.001916041" assertions="1">
|
14
|
+
</testcase>
|
15
|
+
<system-out>
|
16
|
+
</system-out>
|
17
|
+
<system-err>
|
18
|
+
</system-err>
|
19
|
+
</testsuite>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite name="HammerCLIForeman::User::DeleteCommand::parameters" tests="2" time="0.005474158" failures="0" errors="0" skipped="0" assertions="2">
|
3
|
+
<testcase name="test_0001_should accept id" time="0.003096329" assertions="1">
|
4
|
+
</testcase>
|
5
|
+
<testcase name="test_0002_should fail with id missing" time="0.002057597" assertions="1">
|
6
|
+
</testcase>
|
7
|
+
<system-out>
|
8
|
+
</system-out>
|
9
|
+
<system-err>
|
10
|
+
</system-err>
|
11
|
+
</testsuite>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite name="HammerCLIForeman::User::InfoCommand::output" tests="8" time="0.070991386" failures="0" errors="0" skipped="0" assertions="15">
|
3
|
+
<testcase name="test_0006_should print column Last login" time="0.006886969" assertions="2">
|
4
|
+
</testcase>
|
5
|
+
<testcase name="test_0007_should print column Created at" time="0.005724051" assertions="2">
|
6
|
+
</testcase>
|
7
|
+
<testcase name="test_0002_should print column Id" time="0.005450286" assertions="2">
|
8
|
+
</testcase>
|
9
|
+
<testcase name="test_0005_should print column Email" time="0.005539803" assertions="2">
|
10
|
+
</testcase>
|
11
|
+
<testcase name="test_0001_should print 1 records" time="0.005695008" assertions="1">
|
12
|
+
</testcase>
|
13
|
+
<testcase name="test_0004_should print column Name" time="0.005614019" assertions="2">
|
14
|
+
</testcase>
|
15
|
+
<testcase name="test_0003_should print column Login" time="0.0054379" assertions="2">
|
16
|
+
</testcase>
|
17
|
+
<testcase name="test_0008_should print column Updated at" time="0.030227896" assertions="2">
|
18
|
+
</testcase>
|
19
|
+
<system-out>
|
20
|
+
</system-out>
|
21
|
+
<system-err>
|
22
|
+
</system-err>
|
23
|
+
</testsuite>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite name="HammerCLIForeman::User::InfoCommand::parameters" tests="2" time="0.007194698" failures="0" errors="0" skipped="0" assertions="2">
|
3
|
+
<testcase name="test_0002_should fail with no arguments" time="0.001961391" assertions="1">
|
4
|
+
</testcase>
|
5
|
+
<testcase name="test_0001_should accept id" time="0.004686151" assertions="1">
|
6
|
+
</testcase>
|
7
|
+
<system-out>
|
8
|
+
</system-out>
|
9
|
+
<system-err>
|
10
|
+
</system-err>
|
11
|
+
</testsuite>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite name="HammerCLIForeman::User::ListCommand::output" tests="5" time="0.040416447" failures="0" errors="0" skipped="0" assertions="9">
|
3
|
+
<testcase name="test_0001_should print records" time="0.008256648" assertions="1">
|
4
|
+
</testcase>
|
5
|
+
<testcase name="test_0002_should print column Id" time="0.007677963" assertions="2">
|
6
|
+
</testcase>
|
7
|
+
<testcase name="test_0004_should print column Name" time="0.007567883" assertions="2">
|
8
|
+
</testcase>
|
9
|
+
<testcase name="test_0003_should print column Login" time="0.008033693" assertions="2">
|
10
|
+
</testcase>
|
11
|
+
<testcase name="test_0005_should print column Email" time="0.008511567" assertions="2">
|
12
|
+
</testcase>
|
13
|
+
<system-out>
|
14
|
+
</system-out>
|
15
|
+
<system-err>
|
16
|
+
</system-err>
|
17
|
+
</testsuite>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite name="HammerCLIForeman::User::ListCommand::parameters" tests="5" time="0.062271328" failures="0" errors="0" skipped="0" assertions="5">
|
3
|
+
<testcase name="test_0001_should accept no arguments" time="0.006421526" assertions="1">
|
4
|
+
</testcase>
|
5
|
+
<testcase name="test_0002_should accept search" time="0.005973033" assertions="1">
|
6
|
+
</testcase>
|
7
|
+
<testcase name="test_0005_should accept order" time="0.037953243" assertions="1">
|
8
|
+
</testcase>
|
9
|
+
<testcase name="test_0004_should accept page" time="0.005649507" assertions="1">
|
10
|
+
</testcase>
|
11
|
+
<testcase name="test_0003_should accept per page" time="0.005632757" assertions="1">
|
12
|
+
</testcase>
|
13
|
+
<system-out>
|
14
|
+
</system-out>
|
15
|
+
<system-err>
|
16
|
+
</system-err>
|
17
|
+
</testsuite>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite name="HammerCLIForeman::User::UpdateCommand::parameters" tests="2" time="0.004924509" failures="0" errors="0" skipped="0" assertions="2">
|
3
|
+
<testcase name="test_0001_should accept id" time="0.002951368" assertions="1">
|
4
|
+
</testcase>
|
5
|
+
<testcase name="test_0002_should fail with no params" time="0.00166842" assertions="1">
|
6
|
+
</testcase>
|
7
|
+
<system-out>
|
8
|
+
</system-out>
|
9
|
+
<system-err>
|
10
|
+
</system-err>
|
11
|
+
</testsuite>
|
data/test/test_helper.rb
CHANGED
@@ -17,7 +17,7 @@ require "mocha/setup"
|
|
17
17
|
require 'hammer_cli'
|
18
18
|
require 'hammer_cli_foreman/testing/api_expectations'
|
19
19
|
|
20
|
-
FOREMAN_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '1.
|
20
|
+
FOREMAN_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '1.24')
|
21
21
|
|
22
22
|
include HammerCLIForeman::Testing::APIExpectations
|
23
23
|
HammerCLI.context[:api_connection].create('foreman') do
|
@@ -43,7 +43,7 @@ describe HammerCLIForeman::Api::InteractiveBasicAuth do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
context "non-interactive mode" do
|
46
|
-
it "
|
46
|
+
it "doesn't ask for credentials when they're not provided" do
|
47
47
|
auth = HammerCLIForeman::Api::InteractiveBasicAuth.new(nil, nil)
|
48
48
|
auth.expects(:ask_user).never
|
49
49
|
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
|
3
|
+
describe HammerCLIForeman::Api::Oauth::AuthenticationCodeGrant do
|
4
|
+
let(:request) { mock().stubs({}) }
|
5
|
+
let(:args) { {} }
|
6
|
+
let(:params) {{
|
7
|
+
oidc_redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
|
8
|
+
oidc_token_endpoint: 'https://keycloak-server-url.example.com/token',
|
9
|
+
oidc_authorization_endpoint: 'https://keycloak-server-url.example.com/auth/',
|
10
|
+
oidc_client_id: 'hammer-cli-foreman'
|
11
|
+
}}
|
12
|
+
|
13
|
+
describe '#set_token' do
|
14
|
+
let(:auth) { HammerCLIForeman::Api::Oauth::AuthenticationCodeGrant.new(nil, nil, nil, nil) }
|
15
|
+
|
16
|
+
it 'sets token' do
|
17
|
+
auth.stubs(:get_code).returns('code')
|
18
|
+
HammerCLIForeman::OpenidConnect.any_instance.stubs(:get_token_via_2fa).returns('token')
|
19
|
+
auth.set_token(params[:oidc_token_endpoint], params[:oidc_authorization_endpoint], params[:oidc_client_id], params[:oidc_redirect_uri])
|
20
|
+
assert_equal 'token', auth.token
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'sets token as nil when all input parameter are missing' do
|
24
|
+
auth.stubs(:get_code).returns('code')
|
25
|
+
auth.set_token(nil, nil, nil, nil)
|
26
|
+
assert_equal nil, auth.token
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'sets token as nil when any input parameter is missing' do
|
30
|
+
auth.stubs(:get_code).returns('code')
|
31
|
+
auth.set_token(nil, params[:oidc_authorization_endpoint], params[:oidc_client_id], params[:oidc_redirect_uri])
|
32
|
+
assert_equal nil, auth.token
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "interactive mode" do
|
37
|
+
before :each do
|
38
|
+
HammerCLI.stubs(:interactive?).returns true
|
39
|
+
end
|
40
|
+
|
41
|
+
it "asks for url, realm and oidc_client_id when nothing was provided" do
|
42
|
+
auth = HammerCLIForeman::Api::Oauth::AuthenticationCodeGrant.new(nil, nil, nil, nil)
|
43
|
+
auth.stubs(:ask_user).with('Openidc Provider Authorization Endpoint: ').returns(params[:oidc_authorization_endpoint])
|
44
|
+
auth.stubs(:ask_user).with('Openidc Provider Token Endpoint: ').returns(params[:oidc_token_endpoint])
|
45
|
+
auth.stubs(:ask_user).with('Client ID: ').returns(params[:oidc_client_id])
|
46
|
+
auth.stubs(:ask_user).with('Redirect URI: ').returns(params[:oidc_redirect_uri])
|
47
|
+
auth.stubs(:get_code).returns('code')
|
48
|
+
HammerCLIForeman::OpenidConnect.any_instance.stubs(:get_token_via_2fa).returns('token')
|
49
|
+
auth.authenticate(request, args)
|
50
|
+
|
51
|
+
assert_equal request.keys, ['Authorization']
|
52
|
+
assert_equal request.values, ['Bearer token']
|
53
|
+
end
|
54
|
+
|
55
|
+
it "asks for the token endpoint when it wasn't provided" do
|
56
|
+
auth = HammerCLIForeman::Api::Oauth::AuthenticationCodeGrant.new(nil, params[:oidc_authorization_endpoint], params[:oidc_client_id], params[:oidc_redirect_uri])
|
57
|
+
auth.stubs(:ask_user).with('Openidc Provider Token Endpoint: ').returns(params[:oidc_token_endpoint])
|
58
|
+
auth.stubs(:get_code).returns('code')
|
59
|
+
HammerCLIForeman::OpenidConnect.any_instance.stubs(:get_token_via_2fa).returns('token')
|
60
|
+
auth.authenticate(request, args)
|
61
|
+
|
62
|
+
assert_equal request.keys, ['Authorization']
|
63
|
+
assert_equal request.values, ['Bearer token']
|
64
|
+
end
|
65
|
+
|
66
|
+
it "asks for the authorization code endpoint when it wasn't provided" do
|
67
|
+
auth = HammerCLIForeman::Api::Oauth::AuthenticationCodeGrant.new(params[:oidc_token_endpoint], nil, params[:oidc_client_id], params[:oidc_redirect_uri])
|
68
|
+
auth.stubs(:ask_user).with('Openidc Provider Authorization Endpoint: ').returns(params[:oidc_authorization_endpoint])
|
69
|
+
auth.stubs(:get_code).returns('code')
|
70
|
+
HammerCLIForeman::OpenidConnect.any_instance.stubs(:get_token_via_2fa).returns('token')
|
71
|
+
auth.authenticate(request, args)
|
72
|
+
|
73
|
+
assert_equal request.keys, ['Authorization']
|
74
|
+
assert_equal request.values, ['Bearer token']
|
75
|
+
end
|
76
|
+
|
77
|
+
it "asks for the url when url wasn't provided" do
|
78
|
+
auth = HammerCLIForeman::Api::Oauth::AuthenticationCodeGrant.new(params[:oidc_token_endpoint], params[:oidc_authorization_endpoint], nil, params[:oidc_redirect_uri])
|
79
|
+
auth.stubs(:ask_user).with('Client ID: ').returns(params[:oidc_client_id])
|
80
|
+
auth.stubs(:get_code).returns('code')
|
81
|
+
HammerCLIForeman::OpenidConnect.any_instance.stubs(:get_token_via_2fa).returns('token')
|
82
|
+
auth.authenticate(request, args)
|
83
|
+
|
84
|
+
assert_equal request.keys, ['Authorization']
|
85
|
+
assert_equal request.values, ['Bearer token']
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
|
3
|
+
describe HammerCLIForeman::Api::Oauth::PasswordGrant do
|
4
|
+
let(:request) { mock().stubs({}) }
|
5
|
+
let(:args) { {} }
|
6
|
+
let(:params) {{
|
7
|
+
username: 'user1',
|
8
|
+
password: 'password',
|
9
|
+
oidc_token_endpoint: 'https://keycloak-server-url.example.com/token',
|
10
|
+
oidc_client_id: 'hammer-cli-foreman'
|
11
|
+
}}
|
12
|
+
|
13
|
+
describe '#set_token' do
|
14
|
+
let(:auth) { HammerCLIForeman::Api::Oauth::PasswordGrant.new(nil, nil, nil, nil) }
|
15
|
+
|
16
|
+
it 'sets token' do
|
17
|
+
HammerCLIForeman::OpenidConnect.any_instance.stubs(:get_token)
|
18
|
+
.with(params[:username], params[:password]).returns('token')
|
19
|
+
auth.set_token(params[:oidc_token_endpoint], params[:oidc_client_id], params[:username], params[:password])
|
20
|
+
assert_equal 'token', auth.token
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'sets token as nil when all input parameter are missing' do
|
24
|
+
auth.set_token(nil, nil, nil, nil)
|
25
|
+
assert_equal nil, auth.token
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'sets token as nil when any input parameter is missing' do
|
29
|
+
auth.set_token(nil, params[:oidc_client_id], params[:username], params[:password])
|
30
|
+
assert_equal nil, auth.token
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "interactive mode" do
|
35
|
+
before :each do
|
36
|
+
HammerCLI.stubs(:interactive?).returns true
|
37
|
+
end
|
38
|
+
|
39
|
+
it "asks for username, password, url, realm and oidc_client_id when nothing was provided" do
|
40
|
+
auth = HammerCLIForeman::Api::Oauth::PasswordGrant.new(nil, nil, nil, nil)
|
41
|
+
auth.stubs(:ask_user).with('Username: ').returns(params[:username])
|
42
|
+
auth.stubs(:ask_user).with('Password: ', true).returns(params[:password])
|
43
|
+
auth.stubs(:ask_user).with('Openidc Provider Token Endpoint: ').returns(params[:oidc_token_endpoint])
|
44
|
+
auth.stubs(:ask_user).with('Client ID: ').returns(params[:oidc_client_id])
|
45
|
+
HammerCLIForeman::OpenidConnect.any_instance.stubs(:get_token).with(params[:username], params[:password]).returns('token')
|
46
|
+
auth.authenticate(request, args)
|
47
|
+
|
48
|
+
assert_equal request.keys, ['Authorization']
|
49
|
+
assert_equal request.values, ['Bearer token']
|
50
|
+
end
|
51
|
+
|
52
|
+
it "asks for the url when url wasn't provided" do
|
53
|
+
auth = HammerCLIForeman::Api::Oauth::PasswordGrant.new(nil, params[:oidc_client_id], params[:username], params[:password])
|
54
|
+
auth.stubs(:ask_user).with('Openidc Provider Token Endpoint: ').returns(params[:oidc_token_endpoint])
|
55
|
+
HammerCLIForeman::OpenidConnect.any_instance.stubs(:get_token).with(params[:username], params[:password]).returns('token')
|
56
|
+
auth.authenticate(request, args)
|
57
|
+
|
58
|
+
assert_equal request.keys, ['Authorization']
|
59
|
+
assert_equal request.values, ['Bearer token']
|
60
|
+
end
|
61
|
+
|
62
|
+
it "asks for the oidc_client_id when oidc_client_id wasn't provided" do
|
63
|
+
auth = HammerCLIForeman::Api::Oauth::PasswordGrant.new(params[:oidc_token_endpoint], nil, params[:username], params[:password])
|
64
|
+
auth.stubs(:ask_user).with('Client ID: ').returns(params[:oidc_client_id])
|
65
|
+
HammerCLIForeman::OpenidConnect.any_instance.stubs(:get_token).with(params[:username], params[:password]).returns('token')
|
66
|
+
auth.authenticate(request, args)
|
67
|
+
|
68
|
+
assert_equal request.keys, ['Authorization']
|
69
|
+
assert_equal request.values, ['Bearer token']
|
70
|
+
end
|
71
|
+
|
72
|
+
it "asks for the username when username wasn't provided" do
|
73
|
+
auth = HammerCLIForeman::Api::Oauth::PasswordGrant.new(params[:oidc_token_endpoint], params[:oidc_client_id], nil, params[:password])
|
74
|
+
auth.stubs(:ask_user).with('Username: ').returns(params[:username])
|
75
|
+
HammerCLIForeman::OpenidConnect.any_instance.stubs(:get_token).with(params[:username], params[:password]).returns('token')
|
76
|
+
auth.authenticate(request, args)
|
77
|
+
|
78
|
+
assert_equal request.keys, ['Authorization']
|
79
|
+
assert_equal request.values, ['Bearer token']
|
80
|
+
end
|
81
|
+
|
82
|
+
it "asks for the password when password wasn't provided" do
|
83
|
+
auth = HammerCLIForeman::Api::Oauth::PasswordGrant.new(params[:oidc_token_endpoint], params[:oidc_client_id], params[:username], nil)
|
84
|
+
auth.stubs(:ask_user).with('Password: ', true).returns(params[:password])
|
85
|
+
HammerCLIForeman::OpenidConnect.any_instance.stubs(:get_token).with(params[:username], params[:password]).returns('token')
|
86
|
+
auth.authenticate(request, args)
|
87
|
+
|
88
|
+
assert_equal request.keys, ['Authorization']
|
89
|
+
assert_equal request.values, ['Bearer token']
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|