github.com/go-chef/chef@v0.30.1/test_chef_server/test/integration/default/inspec/user_spec.rb (about)

     1  # Inspec tests for the user chef api go module
     2  #
     3  
     4  describe command('/go/src/github.com/go-chef/chef/testapi/bin/user') do
     5    its('stderr') { should match(%r{^Issue creating user POST https://testhost/users: 409}) }
     6    its('stderr') { should match(%r{^Issue creating user err: POST https://testhost/users: 409}) }
     7    its('stderr') { should match(/^Issue creating user code: 409/) }
     8    its('stderr') { should match(/^Issue creating user method: POST/) }
     9    its('stderr') { should match(%r{^Issue creating user url: https://testhost/users}) }
    10    its('stderr') { should_not match(/error|no such file|cannot find|not used|undefined/) }
    11    its('stdout') do
    12      should match(%r{^List initial users map\[(?=.*pivotal:https://testhost/users/pivotal).*\] EndInitialList})
    13    end
    14    # might want a multi line match here to test for expirationdate, key uri and privatekey
    15    its('stdout') do
    16      should match(%r{^Add usr1 \{Uri:https://testhost/users/usr1 ChefKey:\{Name:default PublicKey:-----BEGIN})
    17    end
    18    its('stdout') do
    19      should match(%r{^Add usr2 \{Uri:https://testhost/users/usr2 ChefKey:\{Name:default PublicKey:-----BEGIN})
    20    end
    21    its('stdout') do
    22      should match(%r{^Add usr3 \{Uri:https://testhost/users/usr3 ChefKey:\{Name: PublicKey: ExpirationDate: Uri: PrivateKey:\}\}})
    23    end
    24    its('stdout') { should match(%r{^Filter users map\[usr1:https://testhost/users/usr1\]}) }
    25    its('stdout') { should match(/^Verbose out map\[(?=.*pivotal:)/) }
    26    its('stdout') do
    27      should match(/^Get usr1 \{(?=.*UserName:usr1)(?=.*DisplayName:User1 Fullname)(?=.*Email:user1@domain.io)(?=.*ExternalAuthenticationUid:)(?=.*FirstName:user1)(?=.*LastName:fullname)(?=.*MiddleName:)(?=.*Password:)(?=.*PublicKey:)(?=.*RecoveryAuthenticationEnabled:false).*/)
    28    end
    29    its('stdout') do
    30      should match(/^Pivotal user \{(?=.*UserName:pivotal)(?=.*DisplayName:Chef Server Superuser)(?=.*Email:root@localhost.localdomain)(?=.*ExternalAuthenticationUid:)(?=.*FirstName:Chef)(?=.*LastName:Server)(?=.*MiddleName:)(?=.*Password:)(?=.*PublicKey:)/)
    31    end
    32    its('stdout') do
    33      should match(%r{^List after adding map\[(?=.*pivotal:https://testhost/users/pivotal)(?=.*usr1:https://testhost/users/usr1).*\] EndAddList})
    34    end
    35    its('stdout') do
    36      should match(/^Get usr1 \{(?=.*UserName:usr1)(?=.*DisplayName:User1 Fullname)(?=.*Email:user1@domain.io)(?=.*ExternalAuthenticationUid:)(?=.*FirstName:user1)(?=.*LastName:fullname)(?=.*MiddleName:)(?=.*Password:)(?=.*PublicKey:)/)
    37    end
    38    its('stdout') do
    39      should match(%r{^List after adding map\[(?=.*pivotal:https://testhost/users/pivotal)(?=.*usr1:https://testhost/users/usr1).*\] EndAddList})
    40    end
    41    # TODO: - update and create new private key
    42    # TODO - is admin a thing
    43    its('stdout') { should match(%r{^Update usr1 partial update \{Uri:https://testhost/users/usr1 ChefKey:\{}) }
    44    its('stdout') do
    45      should match(/^Get usr1 after partial update \{(UserName:usr1)(?=.*DisplayName:usr1)(?=.*Email:myuser@samp.com)(?=.*ExternalAuthenticationUid:)(?=.*FirstName:user1)(?=.*LastName:fullname)(?=.*MiddleName:)(?=.*Password:)(?=.*PublicKey:)(?=.*RecoveryAuthenticationEnabled:false).*\}/)
    46    end
    47    its('stdout') do
    48      should match(%r{^Update usr1 full update \{Uri:https://testhost/users/usr1 ChefKey:\{Name: PublicKey: ExpirationDate: Uri: PrivateKey:\}})
    49    end
    50    its('stdout') do
    51      should match(/^Get usr1 after full update \{(UserName:usr1)(?=.*DisplayName:usr1)(?=.*Email:myuser@samp.com)(?=.*ExternalAuthenticationUid:)(?=.*FirstName:user)(?=.*LastName:name)(?=.*MiddleName:mid)(?=.*Password:)(?=.*PublicKey:)(?=.*RecoveryAuthenticationEnabled:false).*\}/)
    52    end
    53    its('stdout') { should match(%r{^Update usr1 rename \{Uri:https://testhost/users/usr1new ChefKey:\{.*\}}) }
    54    its('stdout') do
    55      should match(/^Get usr1 after rename \{(UserName:usr1new)(?=.*DisplayName:usr1)(?=.*Email:myuser@samp.com)(?=.*ExternalAuthenticationUid:)(?=.*FirstName:user)(?=.*LastName:name)(?=.*MiddleName:mid Password:)(?=.*PublicKey:)(?=.*RecoveryAuthenticationEnabled:false).*\}/)
    56    end
    57    its('stdout') { should match(%r{^Delete usr1 DELETE https://testhost/users/usr1: 404}) }
    58    its('stdout') { should match(/^Delete usr1new <nil>/) }
    59    its('stdout') do
    60      should match(%r{^List after cleanup map\[(?=.*pivotal:https://testhost/users/pivotal).*\] EndCleanupList})
    61    end
    62  end