Skip to content

Commit

Permalink
fix: working tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rolljee committed Dec 13, 2024
1 parent eee7900 commit 09a166d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion features/run-kuzzle-stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

# Create the folder where will be stored snapshots
mkdir -p /tmp/snapshots
# chmod 777 -R /tmp/snapshots
chmod 777 -R /tmp/snapshots

# Launch the kuzzle stack
docker compose -f features/docker/docker-compose.yml up -d
Expand Down
1 change: 0 additions & 1 deletion features/step_definitions/common/collection-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Given(
try {
await this.sdk.security.getUser(userId);
} catch (error) {
console.log('✔ User not found, creating...');
await this.sdk.security.createUser(userId, {
content: {
profileIds: ['default']
Expand Down
1 change: 0 additions & 1 deletion src/commands/app/scaffold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export default class AppScaffold extends Kommand {
}

getRepo(flavor: string) {
console.log(flavor);
switch (flavor) {
case "generic":
return "template-kuzzle-project";
Expand Down
1 change: 0 additions & 1 deletion src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ export abstract class Kommand extends Command {
this.logKo(`${e.document._id} : ${e.reason}`);
}
} else {
console.log(error);
this.logKo(JSON.stringify(error.reason));
}

Expand Down
14 changes: 6 additions & 8 deletions src/support/kuzzle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,28 +153,26 @@ export class KuzzleSDK {
* @returns {void}
*/
public async impersonate(userKuid: string, callback: { (): Promise<void> }) {
// const currentToken = this.sdk.jwt;
const currentToken = this.sdk.jwt;

let apiKey: any;

try {
apiKey = await this.security.createApiKey(
userKuid,
"Kourou impersonation token",
{ expiresIn: "2h", refresh: false } as any
{ expiresIn: "2h", refresh: "wait_for" } as any
);

console.log(`Impersonating user ${userKuid}...`, apiKey);

this.sdk.jwt = apiKey._source.token;

await callback();
} finally {
// this.sdk.jwt = currentToken;
this.sdk.jwt = currentToken;

// if (apiKey?._id) {
// await this.security.deleteApiKey(userKuid, apiKey._id);
// }
if (apiKey?._id) {
await this.security.deleteApiKey(userKuid, apiKey._id);
}
}
}

Expand Down

0 comments on commit 09a166d

Please sign in to comment.