Update README to reflect WIP
This commit is contained in:
34
test/workflows/services/TokenService.ts
Normal file
34
test/workflows/services/TokenService.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { ISubscriberTestContext } from '../interfaces/ITestContext';
|
||||
|
||||
export class TokenService {
|
||||
static generateSubscriberToken(context: ISubscriberTestContext): string {
|
||||
try {
|
||||
// Try to import the real TokenBuilder if available
|
||||
const TokenBuilder = require('phenix-edge-auth');
|
||||
const { browser } = require('@wdio/globals');
|
||||
|
||||
const { capabilities: { browserName, browserVersion, platformName } } = browser;
|
||||
|
||||
const subscriberTag = `UAT#${new Date().toISOString()}#SubscribeWorkflow#${context.streamKind}#${browserName}@${browserVersion}:${platformName}`;
|
||||
|
||||
const tokenBuilder = new TokenBuilder()
|
||||
.withApplicationId(context.applicationCredentials.id)
|
||||
.withSecret(context.applicationCredentials.secret)
|
||||
.expiresInSeconds(3600)
|
||||
.forChannel(context.channel.channelId)
|
||||
.applyTags(subscriberTag);
|
||||
|
||||
// Add capabilities if they exist
|
||||
context.publishDestination.capabilities?.forEach(subscriberCapability =>
|
||||
tokenBuilder.withCapability(subscriberCapability)
|
||||
);
|
||||
|
||||
return tokenBuilder.build();
|
||||
} catch (error) {
|
||||
console.warn('Real TokenBuilder not available, using mock token:', error);
|
||||
|
||||
// Return mock token for testing
|
||||
return `mock-token-${Date.now()}-${context.streamKind}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user