mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
adding the get and put methods for the aws amazon password policy commands
This commit is contained in:
parent
362397dd0c
commit
356e246283
5 changed files with 161 additions and 0 deletions
|
@ -37,6 +37,7 @@ module Fog
|
|||
request :delete_user
|
||||
request :delete_user_policy
|
||||
request :get_account_summary
|
||||
request :get_account_password_policy
|
||||
request :get_group
|
||||
request :get_group_policy
|
||||
request :get_instance_profile
|
||||
|
@ -63,6 +64,7 @@ module Fog
|
|||
request :put_group_policy
|
||||
request :put_role_policy
|
||||
request :put_user_policy
|
||||
request :put_account_password_policy
|
||||
request :remove_role_from_instance_profile
|
||||
request :remove_user_from_group
|
||||
request :update_access_key
|
||||
|
|
26
lib/fog/aws/parsers/iam/get_account_password_policy.rb
Normal file
26
lib/fog/aws/parsers/iam/get_account_password_policy.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module IAM
|
||||
class GetAccountPolicyPolicy < Fog::Parsers::Base
|
||||
def reset
|
||||
@response = {'AccountPasswordPolicy' => {}}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'MinimumPasswordLength', 'MaxPasswordAge','PasswordReusePrevention'
|
||||
#boolean values
|
||||
@response['AccountPasswordPolicy'][name] = !!value
|
||||
when 'RequireSymbols','RequireNumbers','RequireUppercaseCharacters','RequireLowercaseCharacters','AllowUsersToChangePassword','HardExpiry','ExpirePasswords'
|
||||
#integer values
|
||||
@response['AccountPasswordPolicy'][name] = value.to_i
|
||||
when 'RequestId'
|
||||
@response[name] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
60
lib/fog/aws/requests/iam/get_account_password_policy.rb
Normal file
60
lib/fog/aws/requests/iam/get_account_password_policy.rb
Normal file
|
@ -0,0 +1,60 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class IAM
|
||||
class Real
|
||||
require 'fog/aws/parsers/iam/get_account_password_policy'
|
||||
|
||||
# Get Account Password Policy
|
||||
#
|
||||
# ==== Parameters
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * MinimumPasswordLength<~integer> Minimum length to require for IAM user passwords.
|
||||
# * MaxPasswordAge<~integer> The number of days that an IAM user password is valid.
|
||||
# * PasswordReusePrevention<~integer> Specifies the number of previous passwords that IAM users are prevented from reusing.
|
||||
# * RequireSymbols<~boolean> Specifies whether to require symbols for IAM user passwords.
|
||||
# * RequireNumbers<~boolean> Specifies whether to require numbers for IAM user passwords.
|
||||
# * RequireUppercaseCharacters<~boolean> Specifies whether to require uppercase characters for IAM user passwords.
|
||||
# * RequireLowercaseCharacters<~boolean> Specifies whether to require lowercase characters for IAM user passwords.
|
||||
# * AllowUsersToChangePassword<~boolean> Specifies whether IAM users are allowed to change their own password.
|
||||
# * HardExpiry<~boolean> Specifies whether IAM users are prevented from setting a new password after their password has expired.
|
||||
# * ExpirePasswords<~boolean> Specifies whether IAM users are required to change their password after a specified number of days.
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.aws.amazon.com/IAM/latest/APIReference/API_GetAccountPasswordPolicy.html
|
||||
#
|
||||
def get_account_password_policy()
|
||||
request({
|
||||
'Action' => 'GetAccountPasswordPolicy',
|
||||
:parser => Fog::Parsers::AWS::IAM::GetAccountPasswordPolicy.new
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_account_password_policy()
|
||||
minimum_password_length, password_reuse_prevention, max_password_age = 5
|
||||
require_symbols, require_numbers, require_uppercase_characters, require_lowercase_characters, allow_users_to_change_password, hard_expiry, expire_passwords = false
|
||||
Excon::Response.new.tap do |response|
|
||||
response.body = {
|
||||
'MinimumPasswordLength' => minimum_password_length,
|
||||
'MaxPasswordAge' => max_password_age,
|
||||
'PasswordReusePrevention' => password_reuse_prevention,
|
||||
'RequireSymbols' => require_symbols,
|
||||
'RequireNumbers' => require_numbers,
|
||||
'RequireUppercaseCharacters' => require_uppercase_characters,
|
||||
'RequireLowercaseCharacters' => require_lowercase_characters,
|
||||
'AllowUsersToChangePassword' => allow_users_to_change_password,
|
||||
'HardExpiry' => hard_expiry,
|
||||
'ExpirePasswords' => expire_passwords,
|
||||
'RequestId' => Fog::AWS::Mock.request_id
|
||||
}
|
||||
response.status = 200
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
56
lib/fog/aws/requests/iam/put_account_password_policy.rb
Normal file
56
lib/fog/aws/requests/iam/put_account_password_policy.rb
Normal file
|
@ -0,0 +1,56 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class IAM
|
||||
class Real
|
||||
require 'fog/aws/parsers/iam/basic'
|
||||
# Add or update the account password policy
|
||||
#
|
||||
# ==== Parameters
|
||||
# * MinimumPasswordLength<~integer> Minimum length to require for IAM user passwords.
|
||||
# * MaxPasswordAge<~integer> The number of days that an IAM user password is valid.
|
||||
# * PasswordReusePrevention<~integer> Specifies the number of previous passwords that IAM users are prevented from reusing.
|
||||
# * RequireSymbols<~boolean> Specifies whether to require symbols for IAM user passwords.
|
||||
# * RequireNumbers<~boolean> Specifies whether to require numbers for IAM user passwords.
|
||||
# * RequireUppercaseCharacters<~boolean> Specifies whether to require uppercase characters for IAM user passwords.
|
||||
# * RequireLowercaseCharacters<~boolean> Specifies whether to require lowercase characters for IAM user passwords.
|
||||
# * AllowUsersToChangePassword<~boolean> Specifies whether IAM users are allowed to change their own password.
|
||||
# * HardExpiry<~boolean> Specifies whether IAM users are prevented from setting a new password after their password has expired.
|
||||
# * ExpirePasswords<~boolean> Specifies whether IAM users are required to change their password after a specified number of days.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'RequestId'<~String> - Id of the request
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/IAM/latest/APIReference/API_PutUserPolicy.html
|
||||
#
|
||||
def put_account_password_policy(minimum_password_length, max_password_age, password_reuse_prevention,require_symbols,require_numbers,require_uppercase_characters, require_lowercase_characters,allow_users_to_change_password, hard_expiry, expire_passwords)
|
||||
request({
|
||||
'Action' => 'UpdateAccountPasswordPolicy',
|
||||
'MinimumPasswordLength' => minimum_password_length,
|
||||
'MaxPasswordAge' => max_password_age,
|
||||
'PasswordReusePrevention' => password_reuse_prevention,
|
||||
'RequireSymbols' => require_symbols,
|
||||
'RequireNumbers' => require_numbers,
|
||||
'RequireUppercaseCharacters' => require_uppercase_characters,
|
||||
'RequireLowercaseCharacters' => require_lowercase_characters,
|
||||
'AllowUsersToChangePassword' => allow_users_to_change_password,
|
||||
'HardExpiry' => hard_expiry,
|
||||
'ExpirePasswords' => expire_passwords,
|
||||
:parser => Fog::Parsers::AWS::IAM::Basic.new
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def put_account_password_policy(minimum_password_length, max_password_age, password_reuse_prevention,require_symbols,require_numbers,require_uppercase_characters, require_lowercase_characters,allow_users_to_change_password, hard_expiry, expire_passwords)
|
||||
Excon::Response.new.tap do |response|
|
||||
response.body = { 'RequestId' => Fog::AWS::Mock.request_id }
|
||||
response.status = 200
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
17
tests/aws/requests/iam/account_policy_tests.rb
Normal file
17
tests/aws/requests/iam/account_policy_tests.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
Shindo.tests('AWS::IAM | account policy requests', ['aws']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
|
||||
tests("#put_account_password_policy(minimum_password_length, max_password_age, password_reuse_prevention,require_symbols,require_numbers,require_uppercase_characters, require_lowercase_characters,allow_users_to_change_password, hard_expiry, expire_passwords)").formats(AWS::IAM::Formats::BASIC) do
|
||||
minimum_password_length, password_reuse_prevention, max_password_age = 5
|
||||
require_symbols, require_numbers, require_uppercase_characters, require_lowercase_characters, allow_users_to_change_password, hard_expiry, expire_passwords = false
|
||||
|
||||
Fog::AWS[:iam].put_account_password_policy(minimum_password_length, max_password_age, password_reuse_prevention,require_symbols,require_numbers,require_uppercase_characters, require_lowercase_characters,allow_users_to_change_password, hard_expiry, expire_passwords).body
|
||||
end
|
||||
|
||||
tests("#get_account_password_policy()") do
|
||||
Fog::AWS[:iam].get_account_password_policy().body['AccountPasswordPolicy']
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue