Use a locally mocked LDAP server for tests (#3652)

This commit is contained in:
Jon Koops 2022-10-27 15:49:10 +02:00 committed by GitHub
parent 2f60e78c4f
commit 4f86ec3da9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 216 additions and 9 deletions

View file

@ -107,6 +107,10 @@ jobs:
with: with:
name: keycloak name: keycloak
- name: Start LDAP server
run: npm run cy:ldap-server &
working-directory: apps/admin-ui
- name: Start Keycloak Server - name: Start Keycloak Server
run: | run: |
tar xfvz keycloak-999-SNAPSHOT.tar.gz tar xfvz keycloak-999-SNAPSHOT.tar.gz

View file

@ -27,12 +27,12 @@ const ldapName = "ldap-mappers-testing";
const ldapVendor = "Active Directory"; const ldapVendor = "Active Directory";
// connection and authentication settings // connection and authentication settings
const connectionUrlValid = "ldap://ldap.forumsys.com:389"; const connectionUrlValid = "ldap://localhost:3004";
const bindTypeSimple = "simple"; const bindTypeSimple = "simple";
const truststoreSpiOnlyLdaps = "Only for ldaps"; const truststoreSpiOnlyLdaps = "Only for ldaps";
const connectionTimeoutTwoSecs = "2000"; const connectionTimeoutTwoSecs = "2000";
const bindDnCnDc = "cn=read-only-admin,dc=example,dc=com"; const bindDnCnDc = "cn=user,dc=test";
const bindCredsValid = "password"; const bindCredsValid = "user";
// ldap searching and updating // ldap searching and updating
const editModeReadOnly = "READ_ONLY"; const editModeReadOnly = "READ_ONLY";

View file

@ -21,12 +21,12 @@ const ldapName = "ldap-mappers-testing";
const ldapVendor = "Active Directory"; const ldapVendor = "Active Directory";
// connection and authentication settings // connection and authentication settings
const connectionUrlValid = "ldap://ldap.forumsys.com:389"; const connectionUrlValid = "ldap://localhost:3004";
const bindTypeSimple = "simple"; const bindTypeSimple = "simple";
const truststoreSpiOnlyLdaps = "Only for ldaps"; const truststoreSpiOnlyLdaps = "Only for ldaps";
const connectionTimeoutTwoSecs = "2000"; const connectionTimeoutTwoSecs = "2000";
const bindDnCnDc = "cn=read-only-admin,dc=example,dc=com"; const bindDnCnDc = "cn=user,dc=test";
const bindCredsValid = "password"; const bindCredsValid = "user";
// ldap searching and updating // ldap searching and updating
const editModeReadOnly = "READ_ONLY"; const editModeReadOnly = "READ_ONLY";

View file

@ -21,12 +21,12 @@ const secondLdapVendor = "Other";
const updatedLdapName = `${firstLdapName}-updated`; const updatedLdapName = `${firstLdapName}-updated`;
// connection and authentication settings // connection and authentication settings
const connectionUrlValid = "ldap://www.zflexldap.com"; const connectionUrlValid = "ldap://localhost:3004";
const bindTypeSimple = "simple"; const bindTypeSimple = "simple";
const truststoreSpiOnlyLdaps = "Only for ldaps"; const truststoreSpiOnlyLdaps = "Only for ldaps";
const connectionTimeoutTwoSecs = "2000"; const connectionTimeoutTwoSecs = "2000";
const bindDnCnDc = "cn=ro_admin,ou=sysadmins,dc=zflexsoftware,dc=com"; const bindDnCnDc = "cn=user,dc=test";
const bindCredsValid = "zflexpass"; const bindCredsValid = "user";
const connectionUrlInvalid = "ldap://nowhere.com"; const connectionUrlInvalid = "ldap://nowhere.com";
const bindTypeNone = "none"; const bindTypeNone = "none";

View file

@ -0,0 +1,4 @@
{
"port": 3004,
"searchBase": "dc=test"
}

View file

@ -0,0 +1,7 @@
[
{
"dn": "cn=user,dc=test",
"objectClass": "person",
"cn": "user-login"
}
]

View file

@ -9,6 +9,7 @@
"cy:open": "cypress open --e2e --browser chrome", "cy:open": "cypress open --e2e --browser chrome",
"cy:run": "cypress run --browser chrome", "cy:run": "cypress run --browser chrome",
"cy:check-types": "tsc --project cypress/tsconfig.json", "cy:check-types": "tsc --project cypress/tsconfig.json",
"cy:ldap-server": "ldap-server-mock --conf=./cypress/fixtures/ldap/server.json --database=./cypress/fixtures/ldap/users.json",
"server:start": "./scripts/start-server.mjs", "server:start": "./scripts/start-server.mjs",
"server:import-client": "./scripts/import-client.mjs" "server:import-client": "./scripts/import-client.mjs"
}, },
@ -99,6 +100,7 @@
"gunzip-maybe": "^1.4.2", "gunzip-maybe": "^1.4.2",
"http2-proxy": "^5.0.53", "http2-proxy": "^5.0.53",
"jsdom": "^20.0.1", "jsdom": "^20.0.1",
"ldap-server-mock": "^5.0.0",
"node-fetch": "^3.2.10", "node-fetch": "^3.2.10",
"progress-promise": "^0.0.6", "progress-promise": "^0.0.6",
"tar-fs": "^2.1.1", "tar-fs": "^2.1.1",

190
package-lock.json generated
View file

@ -178,6 +178,7 @@
"gunzip-maybe": "^1.4.2", "gunzip-maybe": "^1.4.2",
"http2-proxy": "^5.0.53", "http2-proxy": "^5.0.53",
"jsdom": "^20.0.1", "jsdom": "^20.0.1",
"ldap-server-mock": "^5.0.0",
"node-fetch": "^3.2.10", "node-fetch": "^3.2.10",
"progress-promise": "^0.0.6", "progress-promise": "^0.0.6",
"tar-fs": "^2.1.1", "tar-fs": "^2.1.1",
@ -4524,6 +4525,18 @@
"dev": true, "dev": true,
"license": "BSD-3-Clause" "license": "BSD-3-Clause"
}, },
"node_modules/abbrev": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"dev": true
},
"node_modules/abstract-logging": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/abstract-logging/-/abstract-logging-2.0.1.tgz",
"integrity": "sha512-2BjRTZxTPvheOvGbBslFSYOUkr+SjPtOnrLP33f+VIWLzezQpZcqVg7ja3L4dBXmzzgwT+a029jRx5PCi3JuiA==",
"dev": true
},
"node_modules/account-ui": { "node_modules/account-ui": {
"resolved": "apps/account-ui", "resolved": "apps/account-ui",
"link": true "link": true
@ -5031,6 +5044,18 @@
"@babel/core": "^7.0.0-0" "@babel/core": "^7.0.0-0"
} }
}, },
"node_modules/backoff": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/backoff/-/backoff-2.5.0.tgz",
"integrity": "sha512-wC5ihrnUXmR2douXmXLCe5O3zg3GKIyvRi/hi58a/XyRxVI+3/yM0PYueQOZXPXQ9pxBislYkw+sF9b7C/RuMA==",
"dev": true,
"dependencies": {
"precond": "0.2"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/balanced-match": { "node_modules/balanced-match": {
"version": "1.0.2", "version": "1.0.2",
"dev": true, "dev": true,
@ -10092,6 +10117,54 @@
"node": "> 0.8" "node": "> 0.8"
} }
}, },
"node_modules/ldap-filter": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/ldap-filter/-/ldap-filter-0.3.3.tgz",
"integrity": "sha512-/tFkx5WIn4HuO+6w9lsfxq4FN3O+fDZeO9Mek8dCD8rTUpqzRa766BOBO7BcGkn3X86m5+cBm1/2S/Shzz7gMg==",
"dev": true,
"dependencies": {
"assert-plus": "^1.0.0"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/ldap-server-mock": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/ldap-server-mock/-/ldap-server-mock-5.0.0.tgz",
"integrity": "sha512-H1TlHbgyS5OFPPK+5N5foPvuJcg/hNs4B4MZMlK3qAXHgdcjV6UO83K/WCMRIhAB6WBqMn8Y0+hj8xvwB0Ymqg==",
"dev": true,
"dependencies": {
"ldapjs": "^2.3.1",
"nopt": "^5.0.0"
},
"bin": {
"ldap-server-mock": "server.js"
},
"engines": {
"node": ">=16.3.0",
"npm": ">=7.15.1"
}
},
"node_modules/ldapjs": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/ldapjs/-/ldapjs-2.3.3.tgz",
"integrity": "sha512-75QiiLJV/PQqtpH+HGls44dXweviFwQ6SiIK27EqzKQ5jU/7UFrl2E5nLdQ3IYRBzJ/AVFJI66u0MZ0uofKYwg==",
"dev": true,
"dependencies": {
"abstract-logging": "^2.0.0",
"asn1": "^0.2.4",
"assert-plus": "^1.0.0",
"backoff": "^2.5.0",
"ldap-filter": "^0.3.3",
"once": "^1.4.0",
"vasync": "^2.2.0",
"verror": "^1.8.1"
},
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/levn": { "node_modules/levn": {
"version": "0.4.1", "version": "0.4.1",
"dev": true, "dev": true,
@ -10856,6 +10929,21 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/nopt": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz",
"integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==",
"dev": true,
"dependencies": {
"abbrev": "1"
},
"bin": {
"nopt": "bin/nopt.js"
},
"engines": {
"node": ">=6"
}
},
"node_modules/normalize-path": { "node_modules/normalize-path": {
"version": "3.0.0", "version": "3.0.0",
"dev": true, "dev": true,
@ -11508,6 +11596,15 @@
"node": "^10 || ^12 || >=14" "node": "^10 || ^12 || >=14"
} }
}, },
"node_modules/precond": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/precond/-/precond-0.2.3.tgz",
"integrity": "sha512-QCYG84SgGyGzqJ/vlMsxeXd/pgL/I94ixdNFyh1PusWmTCyVfPJjZ1K1jvHtsbfnXQs2TSkEP2fR7QiMZAnKFQ==",
"dev": true,
"engines": {
"node": ">= 0.6"
}
},
"node_modules/prelude-ls": { "node_modules/prelude-ls": {
"version": "1.2.1", "version": "1.2.1",
"dev": true, "dev": true,
@ -14144,6 +14241,18 @@
"version": "1.0.1", "version": "1.0.1",
"license": "MIT" "license": "MIT"
}, },
"node_modules/vasync": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/vasync/-/vasync-2.2.1.tgz",
"integrity": "sha512-Hq72JaTpcTFdWiNA4Y22Amej2GH3BFmBaKPPlDZ4/oC8HNn2ISHLkFrJU4Ds8R3jcUi7oo5Y9jcMHKjES+N9wQ==",
"dev": true,
"engines": [
"node >=0.6.0"
],
"dependencies": {
"verror": "1.10.0"
}
},
"node_modules/verror": { "node_modules/verror": {
"version": "1.10.0", "version": "1.10.0",
"dev": true, "dev": true,
@ -17936,6 +18045,18 @@
"version": "2.0.6", "version": "2.0.6",
"dev": true "dev": true
}, },
"abbrev": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"dev": true
},
"abstract-logging": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/abstract-logging/-/abstract-logging-2.0.1.tgz",
"integrity": "sha512-2BjRTZxTPvheOvGbBslFSYOUkr+SjPtOnrLP33f+VIWLzezQpZcqVg7ja3L4dBXmzzgwT+a029jRx5PCi3JuiA==",
"dev": true
},
"account-ui": { "account-ui": {
"version": "file:apps/account-ui", "version": "file:apps/account-ui",
"requires": { "requires": {
@ -18062,6 +18183,7 @@
"i18next-http-backend": "^1.4.4", "i18next-http-backend": "^1.4.4",
"jsdom": "^20.0.1", "jsdom": "^20.0.1",
"keycloak-js": "999.0.0-dev", "keycloak-js": "999.0.0-dev",
"ldap-server-mock": "^5.0.0",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"node-fetch": "^3.2.10", "node-fetch": "^3.2.10",
"progress-promise": "^0.0.6", "progress-promise": "^0.0.6",
@ -18387,6 +18509,15 @@
"@babel/helper-define-polyfill-provider": "^0.3.3" "@babel/helper-define-polyfill-provider": "^0.3.3"
} }
}, },
"backoff": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/backoff/-/backoff-2.5.0.tgz",
"integrity": "sha512-wC5ihrnUXmR2douXmXLCe5O3zg3GKIyvRi/hi58a/XyRxVI+3/yM0PYueQOZXPXQ9pxBislYkw+sF9b7C/RuMA==",
"dev": true,
"requires": {
"precond": "0.2"
}
},
"balanced-match": { "balanced-match": {
"version": "1.0.2", "version": "1.0.2",
"dev": true "dev": true
@ -21650,6 +21781,41 @@
"version": "1.6.0", "version": "1.6.0",
"dev": true "dev": true
}, },
"ldap-filter": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/ldap-filter/-/ldap-filter-0.3.3.tgz",
"integrity": "sha512-/tFkx5WIn4HuO+6w9lsfxq4FN3O+fDZeO9Mek8dCD8rTUpqzRa766BOBO7BcGkn3X86m5+cBm1/2S/Shzz7gMg==",
"dev": true,
"requires": {
"assert-plus": "^1.0.0"
}
},
"ldap-server-mock": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/ldap-server-mock/-/ldap-server-mock-5.0.0.tgz",
"integrity": "sha512-H1TlHbgyS5OFPPK+5N5foPvuJcg/hNs4B4MZMlK3qAXHgdcjV6UO83K/WCMRIhAB6WBqMn8Y0+hj8xvwB0Ymqg==",
"dev": true,
"requires": {
"ldapjs": "^2.3.1",
"nopt": "^5.0.0"
}
},
"ldapjs": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/ldapjs/-/ldapjs-2.3.3.tgz",
"integrity": "sha512-75QiiLJV/PQqtpH+HGls44dXweviFwQ6SiIK27EqzKQ5jU/7UFrl2E5nLdQ3IYRBzJ/AVFJI66u0MZ0uofKYwg==",
"dev": true,
"requires": {
"abstract-logging": "^2.0.0",
"asn1": "^0.2.4",
"assert-plus": "^1.0.0",
"backoff": "^2.5.0",
"ldap-filter": "^0.3.3",
"once": "^1.4.0",
"vasync": "^2.2.0",
"verror": "^1.8.1"
}
},
"levn": { "levn": {
"version": "0.4.1", "version": "0.4.1",
"dev": true, "dev": true,
@ -22171,6 +22337,15 @@
"version": "2.0.6", "version": "2.0.6",
"dev": true "dev": true
}, },
"nopt": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz",
"integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==",
"dev": true,
"requires": {
"abbrev": "1"
}
},
"normalize-path": { "normalize-path": {
"version": "3.0.0", "version": "3.0.0",
"dev": true "dev": true
@ -22574,6 +22749,12 @@
"source-map-js": "^1.0.2" "source-map-js": "^1.0.2"
} }
}, },
"precond": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/precond/-/precond-0.2.3.tgz",
"integrity": "sha512-QCYG84SgGyGzqJ/vlMsxeXd/pgL/I94ixdNFyh1PusWmTCyVfPJjZ1K1jvHtsbfnXQs2TSkEP2fR7QiMZAnKFQ==",
"dev": true
},
"prelude-ls": { "prelude-ls": {
"version": "1.2.1", "version": "1.2.1",
"dev": true "dev": true
@ -24325,6 +24506,15 @@
"value-equal": { "value-equal": {
"version": "1.0.1" "version": "1.0.1"
}, },
"vasync": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/vasync/-/vasync-2.2.1.tgz",
"integrity": "sha512-Hq72JaTpcTFdWiNA4Y22Amej2GH3BFmBaKPPlDZ4/oC8HNn2ISHLkFrJU4Ds8R3jcUi7oo5Y9jcMHKjES+N9wQ==",
"dev": true,
"requires": {
"verror": "1.10.0"
}
},
"verror": { "verror": {
"version": "1.10.0", "version": "1.10.0",
"dev": true, "dev": true,