Skip to content

Commit

Permalink
Fix ldif script to work with latest version of node. Add a usersPerGr…
Browse files Browse the repository at this point in the history
…oup variable so we don't add every user to every group.
  • Loading branch information
ggreer committed Aug 19, 2024
1 parent fb8c803 commit 5dddfb4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ jobs:
- name: Run baton-ldap
run: ./baton-ldap
- name: Revoke grants
run: ./baton-ldap --revoke-grant 'group:cn=testgroup00000,dc=example,dc=org:member:user:cn=testuser00999@example.com,dc=example,dc=org' && ./baton-ldap --revoke-grant 'group:cn=othertestgroup00000,dc=example,dc=org:member:user:cn=testuser00999@example.com,dc=example,dc=org'
run: ./baton-ldap --revoke-grant 'group:cn=testgroup00000,dc=example,dc=org:member:user:cn=testuser00099@example.com,dc=example,dc=org' && ./baton-ldap --revoke-grant 'group:cn=othertestgroup00000,dc=example,dc=org:member:user:cn=testuser00099@example.com,dc=example,dc=org'
- name: Grant entitlements
run: ./baton-ldap --grant-entitlement 'group:cn=testgroup00000,dc=example,dc=org:member' --grant-principal 'cn=testuser00999@example.com,dc=example,dc=org' --grant-principal-type 'user' && ./baton-ldap --grant-entitlement 'group:cn=othertestgroup00000,dc=example,dc=org:member' --grant-principal 'cn=testuser00999@example.com,dc=example,dc=org' --grant-principal-type 'user'
run: ./baton-ldap --grant-entitlement 'group:cn=testgroup00000,dc=example,dc=org:member' --grant-principal 'cn=testuser00099@example.com,dc=example,dc=org' --grant-principal-type 'user' && ./baton-ldap --grant-entitlement 'group:cn=othertestgroup00000,dc=example,dc=org:member' --grant-principal 'cn=testuser00099@example.com,dc=example,dc=org' --grant-principal-type 'user'
11 changes: 7 additions & 4 deletions scripts/ldif.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ const fs = require('node:fs');
const userCount = 1000;
const groupCount = 50;
const maxFileSize = 2000000; // php ldap admin has a 2MB limit
const usersPerGroup = 100;

let fileSize = 0;
let fileCount = 0;
const baseFileName = "big-";

let f;
let f = null;
// Only pass strings that constitute full objects to write().
// Otherwise the object will span across multiple files and import will fail.
function write (data, opts = {}) {
fileSize += data.length;
if (fileSize > maxFileSize) {
fs.closeSync(f);
if (f) {
fs.closeSync(f);
}
fileSize = data.length;
fileCount++;
f = null;
Expand Down Expand Up @@ -56,7 +59,7 @@ cn: testgroup${groupIdStr}
gidNumber: ${groupId}
`;

for (let userId = 0; userId < userCount; userId++) {
for (let userId = 0; userId < usersPerGroup; userId++) {
const userIdStr = ("00000" + userId).slice(-5);
groupStr += `memberUid: testuser${userIdStr}@example.com
`;
Expand All @@ -75,7 +78,7 @@ cn: othertestgroup${groupIdStr}
owner: [email protected],dc=example,dc=org
`;

for (let userId = 0; userId < userCount; userId++) {
for (let userId = 0; userId < usersPerGroup; userId++) {
const userIdStr = ("00000" + userId).slice(-5);
groupStr += `uniquemember: cn=testuser${userIdStr}@example.com,dc=example,dc=org
`;
Expand Down

0 comments on commit 5dddfb4

Please sign in to comment.