Skip to content
Snippets Groups Projects
Commit 4d5e50ed authored by Christian ZHENG's avatar Christian ZHENG
Browse files

refactor(login): rewrite test class

parent d94042b2
No related branches found
No related tags found
2 merge requests!14feat: added mounted, .bashrc, .zshrc, added tests, added keycloak tests,!8feat(extension): login, open in devcontainer, automaticly save code, open briefing, publish extension
import { log } from 'recorder/utils';
import KeycloakOAuth2DeviceFlowConnection from './keycloakOAuth2DeviceFlowConnection';
/**
* Maybe temporary file ?\
* This class shows how to use KeycloakOAuth2DeviceFlowConnection.\
* It is currently based on dev.deadlock instance\
* but there are only some urls to change for further testings.
*
*/
export default class KeycloakOAuth2DeviceFlowConnectionTest {
public connection: KeycloakOAuth2DeviceFlowConnection;
constructor() {
log(' --- KeycloakOAuth2DeviceFlowConnectionTest --- ');
this.connection = new KeycloakOAuth2DeviceFlowConnection(
'https://auth.dev.deadlock.io/auth/realms/Deadlock/protocol/openid-connect/auth/device',
'https://auth.dev.deadlock.io/auth/realms/Deadlock/protocol/openid-connect/token',
);
}
public run(): void {}
/**
* Simple working examples
*/
public async run() {
const openLinkPlaceholder = (link: string) => {
log(`click here: ${link}`);
};
let tokens = await this.connection.getToken({ openLink: openLinkPlaceholder });
console.log('tokens', tokens);
if (!tokens?.refreshToken) {
console.log("refresh token doesn't exist");
return;
}
let refreshedTokens = await this.connection.getToken({
refreshToken: tokens.refreshToken,
openLink: openLinkPlaceholder,
});
console.log('refreshed tokens', refreshedTokens);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment