Debian Codegraph @

spec/acceptance/userlist_spec.rb

raw
1 # frozen_string_literal: true
2
3 require 'spec_helper_acceptance'
4
5 describe 'userlist define' do
6 pp_one = <<-PUPPETCODE
7 class { 'haproxy': }
8 haproxy::userlist { 'users_groups':
9 users => [
10 'test1 insecure-password elgato',
11 'test2 insecure-password elgato',
12 '',
13 ],
14 groups => [
15 'g1 users test1',
16 '',
17 ]
18 }
19
20 haproxy::listen { 'app00':
21 collect_exported => false,
22 ipaddress => $facts['networking']['interfaces']['lo']['ip'],
23 ports => '5555',
24 options => {
25 'mode' => 'http',
26 'acl' => 'auth_ok http_auth(users_groups)',
27 'http-request' => 'auth realm Okay if !auth_ok',
28 },
29 }
30 haproxy::balancermember { 'app00 port 5556':
31 listening_service => 'app00',
32 server_names => 'test00.example.com',
33 ports => '5556',
34 }
35
36 haproxy::listen { 'app01':
37 collect_exported => false,
38 ipaddress => $facts['networking']['interfaces']['lo']['ip'],
39 ports => '5554',
40 options => {
41 'mode' => 'http',
42 'acl' => 'auth_ok http_auth_group(users_groups) g1',
43 'http-request' => 'auth realm Okay if !auth_ok',
44 },
45 }
46 haproxy::balancermember { 'app01 port 5556':
47 listening_service => 'app01',
48 ports => '5556',
49 }
50 PUPPETCODE
51 it 'is able to configure the listen with puppet' do
52 # C9966 C9970
53 retry_on_error_matching do
54 apply_manifest(pp_one, catch_failures: true)
55 end
56 end
57
58 # C9957
59 it 'test1 should auth as user' do
60 expect(run_shell('curl http://test1:elgato@localhost:5555').stdout.chomp).to eq('Response on 5556')
61 end
62
63 it 'test2 should auth as user' do
64 expect(run_shell('curl http://test2:elgato@localhost:5555').stdout.chomp).to eq('Response on 5556')
65 end
66
67 # C9958
68 it 'does not auth as user' do
69 expect(run_shell('curl http://test3:elgato@localhost:5555').stdout.chomp).not_to eq('Response on 5556')
70 end
71
72 # C9959
73 it 'auths as group' do
74 expect(run_shell('curl http://test1:elgato@localhost:5554').stdout.chomp).to eq('Response on 5556')
75 end
76
77 # C9960
78 it 'does not auth as group' do
79 expect(run_shell('curl http://test2:elgato@localhost:5554').stdout.chomp).not_to eq('Response on 5556')
80 end
81
82 # C9965 C9967 C9968 C9969 WONTFIX
83 end