| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | set -e |
| 3 | |
| 4 | generateCertscip-shell shell shell-project 0.0.0 generateCert(). () { |
| 5 | opensslscip-shell system . . openssl. genrsa -out server.key 2048 |
| 6 | opensslscip-shell system . . openssl. req -new -key server.key -out server.csr -subj "/C=XX/CN=bonsai.testscip-shell filesystem . . `/C=XX/CN=bonsai.test`." |
| 7 | opensslscip-shell system . . openssl. x509 -req -days 500 -in server.csr -CA ./tests/testenv/certs/cacert.pem -CAkey ./tests/testenv/certs/cacert.key -CAcreateserial -out server.pem -sha256 |
| 8 | echoscip-shell system . . echo. "Server cert is generated..." |
| 9 | |
| 10 | mkdirscip-shell system . . mkdir. -p /usr/local/var/openldap-certsscip-shell filesystem . . `/usr/local/var/openldap-certs`. |
| 11 | |
| 12 | cpscip-shell system . . cp. ./tests/testenv/certs/cacert.pem /usr/local/var/openldap-certs/scip-shell filesystem . . `/usr/local/var/openldap-certs/`. |
| 13 | mvscip-shell system . . mv. server.key /usr/local/var/openldap-certs/scip-shell filesystem . . `/usr/local/var/openldap-certs/`. |
| 14 | mvscip-shell system . . mv. server.pem /usr/local/var/openldap-certs/scip-shell filesystem . . `/usr/local/var/openldap-certs/`. |
| 15 | echoscip-shell system . . echo. "Moved certs..." |
| 16 | } |
| 17 | |
| 18 | setLDAPscip-shell shell shell-project 0.0.0 setLDAP(). () { |
| 19 | sudoscip-shell system . . sudo. /usr/local/opt/openldap/libexec/slapdscip-shell filesystem . . `/usr/local/opt/openldap/libexec/slapd`. -h "ldap:// ldapi:// ldaps://" |
| 20 | sleepscip-shell system . . sleep. 4 |
| 21 | echoscip-shell system . . echo. "Slapd is started..." |
| 22 | psscip-shell system . . ps. aux | grepscip-shell system . . grep. slapd |
| 23 | # Change jpeg file path. |
| 24 | sedscip-shell system . . sed. -i.bak "s|/home/ldap/test.jpeg|$TRAVIS_BUILD_DIR/tests/testenv/test.jpeg|g" ./tests/testenv/ldifs/base.ldif |
| 25 | # Create base entry and populate the dictionary. |
| 26 | ldapadd -x -D "cn=admin,dc=bonsai,dc=test" -w p@ssword -H ldap:/// -f ./tests/testenv/ldifs/base.ldif |
| 27 | ldapadd -x -D "cn=admin,dc=bonsai,dc=test" -w p@ssword -H ldap:/// -f ./tests/testenv/ldifs/users.ldif |
| 28 | ldapadd -x -D "cn=admin,dc=bonsai,dc=test" -w p@ssword -H ldap:/// -f ./tests/testenv/ldifs/referrals.ldif |
| 29 | echoscip-shell system . . echo. "Directory is populated..." |
| 30 | # Set default password policy. |
| 31 | ldapadd -x -D "cn=admin,dc=bonsai,dc=test" -w p@ssword -H ldap:/// -f ./tests/testenv/ldifs/ppolicy.ldif |
| 32 | # Stop the slapd. |
| 33 | sudoscip-shell system . . sudo. kill $(psscip-shell system . . ps. aux | grepscip-shell system . . grep. /usr/local/opt/openldap/libexec/slapdscip-shell filesystem . . `/usr/local/opt/openldap/libexec/slapd`. | grepscip-shell system . . grep. -v grep | awkscip-shell system . . awk. '{print $2}') |
| 34 | echoscip-shell system . . echo. "Slapd is stopped..." |
| 35 | } |
| 36 | |
| 37 | #Set passsword for SASL DIGEST-MD5. |
| 38 | setDigestscip-shell shell shell-project 0.0.0 setDigest(). () { |
| 39 | echoscip-shell system . . echo. "p@ssword" | sudoscip-shell system . . sudo. /usr/local/opt/cyrussasl/sbin/saslpasswd2scip-shell filesystem . . `/usr/local/opt/cyrussasl/sbin/saslpasswd2`. -p -c admin |
| 40 | echoscip-shell system . . echo. "p@ssword" | sudoscip-shell system . . sudo. /usr/local/opt/cyrussasl/sbin/saslpasswd2scip-shell filesystem . . `/usr/local/opt/cyrussasl/sbin/saslpasswd2`. -p -c chuck |
| 41 | echoscip-shell system . . echo. "Passwords are set..." |
| 42 | } |
| 43 | |
| 44 | generateCertscip-shell shell shell-project 0.0.0 generateCert(). |
| 45 | setDigestscip-shell shell shell-project 0.0.0 setDigest(). |
| 46 | setLDAPscip-shell shell shell-project 0.0.0 setLDAP(). |