Skip to content

Commit 05e78de

Browse files
author
Anton Ustyuzhanin
committed
Add molecule tests
1 parent a8cec3e commit 05e78de

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

molecule/default/molecule.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ provisioner:
3232
group_vars:
3333
all:
3434
sssd_ldap_search_base: dc=example,dc=com
35+
sssd_ldap_user_search_base: dc=example,dc=com?subtree?(uidNumber=5000)
3536
sssd_ldap_uri: ldap://localhost
3637
sssd_ldap_default_bind_dn: cn=Manager,dc=example,dc=com
3738
sssd_ldap_default_authtok: s3cr3t

molecule/default/prepare.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
- name: install python-ldap
2020
package:
2121
name: python-ldap
22-
- name: Make sure we have an test user
22+
- name: Make sure we have two test users
2323
ldap_entry:
2424
bind_dn: cn=Manager,dc=example,dc=com
2525
bind_pw: s3cr3t
26-
dn: cn=test,dc=example,dc=com
26+
dn: 'uid={{ item.uid }},dc=example,dc=com'
2727
objectClass:
2828
- top
2929
- person
@@ -32,15 +32,24 @@
3232
- organizationalPerson
3333
- ldapPublicKey
3434
attributes:
35+
uid: "{{ item.uid }}"
36+
uidNumber: "{{ item.uidNumber }}"
37+
givenName: "{{ item.name }}"
38+
sn: "{{ item.name }}"
39+
cn: "{{ item.name }}"
40+
loginShell: /bin/bash
41+
homeDirectory: "/home/{{ item.uid }}"
42+
sshPublicKey: "{{ item.sshPublicKey }}"
43+
gidNumber: "{{ item.uidNumber }}"
44+
with_items:
45+
- name: Test
3546
uid: test
3647
uidNumber: 5000
37-
givenName: Test
38-
sn: Test
39-
cn: Test
40-
loginShell: /bin/bash
41-
homeDirectory: /home/test
4248
sshPublicKey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYaGyXcqdQUIxjPr3eqXro9X/2LrLH2o+OrFeGRB2u3WxigroynxD8vLjtG6qyYYtgnvR9+2usVhbNNS3QdF3G5wenCR4Zpk6VIYofQrBYmrzJG9Bsig3G4SgnGF2x4KimupjCdD4+1S9OMF/4GzQZdaLl2HkSTYE+6430FbSD8i3IdpbRI526X8q4njrTHgIYUtAVFTPSudZ/3fIzFpfNlWq5wy1CXCGc7aqmHECQzareeoAM5NfgrUkw7TFrKP/zelDkqpJ6pwYTWg2VZYmoXmh2o+ttWFatGzJPUoeU/r+SjMn4YvMunT+L6NIrbJQkXwB9i3upMx2bQcuPl0cl test-key
43-
gidNumber: 5000
49+
- name: Filtered
50+
uid: filtered-test
51+
uidNumber: 5001
52+
sshPublicKey: ''
4453
- name: create /root/.ssh dir
4554
file:
4655
path: /root/.ssh

molecule/default/tests/test_default.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ def test_sssd_ldap_user(host):
1919
assert user.uid == 5000
2020
assert user.gid == 1
2121

22+
def test_sssd_ldap_user_filtered(host):
23+
user = host.user('filtered-test')
24+
assert not user.exists
25+
2226

2327
def test_sssd_service_state(host):
2428
assert host.service('sssd').is_enabled

0 commit comments

Comments
 (0)