feat(core): Add delete user functionality and necessary tests
This commit is contained in:
parent
66a4bf6142
commit
6ab9ab2c59
@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2024-08-27 - 1.1.0 - feat(core)
|
||||||
|
Add delete user functionality and necessary tests
|
||||||
|
|
||||||
|
- Implemented delete method in ZitadelUser class.
|
||||||
|
- Extended tests to cover user deletion functionality.
|
||||||
|
- Refactored createUser method to return a ZitadelUser instance.
|
||||||
|
|
||||||
## 2024-08-26 - 1.0.9 - fix(dependencies)
|
## 2024-08-26 - 1.0.9 - fix(dependencies)
|
||||||
Update dependencies to latest versions
|
Update dependencies to latest versions
|
||||||
|
|
||||||
|
15
test/test.ts
15
test/test.ts
@ -24,15 +24,24 @@ tap.test('should list users', async () => {
|
|||||||
const users = await testZitadel.listUsers();
|
const users = await testZitadel.listUsers();
|
||||||
expect(users).toBeArray();
|
expect(users).toBeArray();
|
||||||
expect(users[0]).toBeInstanceOf(zitadel.ZitaldelUser);
|
expect(users[0]).toBeInstanceOf(zitadel.ZitaldelUser);
|
||||||
console.log(users);
|
console.log(JSON.stringify(users, null, 2));
|
||||||
})
|
})
|
||||||
|
|
||||||
tap.test('should invite user', async () => {
|
const createUserTest = tap.test('should invite user', async (toolsArg) => {
|
||||||
await testZitadel.createUser({
|
const user = await testZitadel.createUser({
|
||||||
email: await testQenv.getEnvVarOnDemand('ZITADEL_TEST_EMAIL'),
|
email: await testQenv.getEnvVarOnDemand('ZITADEL_TEST_EMAIL'),
|
||||||
firstName: 'firstname',
|
firstName: 'firstname',
|
||||||
lastName: 'lastname',
|
lastName: 'lastname',
|
||||||
})
|
})
|
||||||
|
await toolsArg.delayFor(5000);
|
||||||
|
return user;
|
||||||
|
})
|
||||||
|
|
||||||
|
tap.test('should delete user', async () => {
|
||||||
|
const createdUser: zitadel.ZitaldelUser = (await createUserTest.testResultPromise) as any;
|
||||||
|
expect(createdUser).toBeInstanceOf(zitadel.ZitaldelUser);
|
||||||
|
await createdUser.delete();
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export default tap.start()
|
export default tap.start()
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@apiclient.xyz/zitadel',
|
name: '@apiclient.xyz/zitadel',
|
||||||
version: '1.0.9',
|
version: '1.1.0',
|
||||||
description: 'An unofficial client for interacting with Zitadel API, enabling user and project management functionalities.'
|
description: 'An unofficial client for interacting with Zitadel API, enabling user and project management functionalities.'
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,12 @@ export class ZitaldelClient {
|
|||||||
familyName: optionsArg.lastName,
|
familyName: optionsArg.lastName,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log(response);
|
// const allUsers = await this.listUsers();
|
||||||
|
// console.log(JSON.stringify(allUsers, null, 2));
|
||||||
|
return new ZitaldelUser(this, {
|
||||||
|
id: response.userId,
|
||||||
|
lastLogin: null,
|
||||||
|
username: optionsArg.email,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,4 +64,13 @@ export class ZitaldelUser {
|
|||||||
userId: this.data.id,
|
userId: this.data.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deletes the user
|
||||||
|
*/
|
||||||
|
public async delete() {
|
||||||
|
const response = await this.zitadelclientRef.userClient.deleteUser({
|
||||||
|
userId: this.data.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user