From 73abc68cb432189319a4b0aa4adcb905a82f4f16 Mon Sep 17 00:00:00 2001 From: stonezdj Date: Wed, 29 Nov 2017 19:29:51 +0800 Subject: [PATCH] Add LDAP e2e test --- tests/ldap_test.ldif | 39 +++++++++++++++++++ tests/resources/Docker-Util.robot | 6 +++ .../Harbor-Pages/Configuration.robot | 2 + tests/robot-cases/Group0-BAT/BAT.robot | 13 +++++-- 4 files changed, 56 insertions(+), 4 deletions(-) diff --git a/tests/ldap_test.ldif b/tests/ldap_test.ldif index a2b663367..b9dbcc9a5 100644 --- a/tests/ldap_test.ldif +++ b/tests/ldap_test.ldif @@ -1,3 +1,4 @@ +# User entry doesn't belong to harbor_users, it should fail to login dn: uid=test,dc=example,dc=com uid: test cn: test @@ -12,3 +13,41 @@ gidNumber: 1001 userPassword: 123456 mail: test@example.com gecos: test + +# OU for People +dn: ou=people,dc=example,dc=com +objectClass: organizationalUnit +ou: People + +# OU for Groups +dn: ou=groups,dc=example,dc=com +objectClass: organizationalUnit +ou: Groups + +# Group Entry harbor_users +dn: cn=harbor_users,ou=groups,dc=example,dc=com +cn: harbor_users +description: All users +member: cn=mike,ou=people,dc=example,dc=com +objectclass: groupOfNames +objectclass: top + +# User belongs to harbor_user +dn: cn=mike,ou=people,dc=example,dc=com +cn: mike +gidnumber: 10000 +givenname: mike +homedirectory: /home/mike +loginshell: /bin/bash +mail: mike@example.com +objectclass: top +objectclass: posixAccount +objectclass: shadowAccount +objectclass: inetOrgPerson +objectclass: organizationalPerson +objectclass: person +sn: Joe +uid: mike +uidnumber: 5000 +userpassword: {MD5}wb68DeX0CyENafzUADNn9A== +memberof: cn=harbor_users,ou=groups,dc=example,dc=com \ No newline at end of file diff --git a/tests/resources/Docker-Util.robot b/tests/resources/Docker-Util.robot index 1fb4a3bfe..10efeccfa 100644 --- a/tests/resources/Docker-Util.robot +++ b/tests/resources/Docker-Util.robot @@ -132,3 +132,9 @@ Kill Local Docker Daemon Process Should Be Stopped ${handle} ${rc}= Run And Return Rc kill -9 ${dockerd-pid} Should Be Equal As Integers ${rc} 0 + +Docker Login Fail + [Arguments] ${ip} ${user} ${pwd} + Log To Console \nRunning docker login ${ip} ... + ${rc} ${output}= Run And Return Rc And Output docker login -u ${user} -p ${pwd} ${ip} + Should Not Be Equal As Integers ${rc} 0 diff --git a/tests/resources/Harbor-Pages/Configuration.robot b/tests/resources/Harbor-Pages/Configuration.robot index ccb780b3b..14a6a928d 100644 --- a/tests/resources/Harbor-Pages/Configuration.robot +++ b/tests/resources/Harbor-Pages/Configuration.robot @@ -32,6 +32,8 @@ Init LDAP Sleep 1 Input Text xpath=//*[@id="ldapBaseDN"] dc=example,dc=com Sleep 1 + Input Text xpath=//*[@id="ldapFilter"] (&(objectclass=inetorgperson)(memberof=cn=harbor_users,ou=groups,dc=example,dc=com)) + Sleep 1 Input Text xpath=//*[@id="ldapUid"] cn Sleep 1 Capture Page Screenshot diff --git a/tests/robot-cases/Group0-BAT/BAT.robot b/tests/robot-cases/Group0-BAT/BAT.robot index 1fd7ea6db..9ce626c82 100644 --- a/tests/robot-cases/Group0-BAT/BAT.robot +++ b/tests/robot-cases/Group0-BAT/BAT.robot @@ -343,26 +343,31 @@ Test Case - Ldap Sign in and out Switch To Configure Init LDAP Logout Harbor - Sign In Harbor ${HARBOR_URL} test 123456 + Sign In Harbor ${HARBOR_URL} mike zhu88jie Close Browser Test Case - Ldap User Create Project Init Chrome Driver ${d}= Get Current Date result_format=%m%s - Sign In Harbor ${HARBOR_URL} test 123456 + Sign In Harbor ${HARBOR_URL} mike zhu88jie Create An New Project project${d} Close Browser Test Case - Ldap User Push An Image Init Chrome Driver ${d}= Get Current Date result_format=%m%s - Sign In Harbor ${HARBOR_URL} test 123456 + Sign In Harbor ${HARBOR_URL} mike zhu88jie Create An New Project project${d} - Push Image ${ip} test 123456 project${d} hello-world:latest + Push Image ${ip} mike zhu88jie project${d} hello-world:latest Go Into Project project${d} Wait Until Page Contains project${d}/hello-world Close Browser +Test Case - Ldap User Can Not login + Docker Login Fail ${ip} test 123456 + Test Case - Clean Harbor Images Down Harbor + +