CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-azure--core-auth

Provides low-level interfaces and helper methods for authentication in Azure SDK

Overall
score

97%

Overview
Eval results
Files

task.mdevals/scenario-8/

Azure Service Configuration Manager

Build a configuration manager for an Azure service client that handles API key authentication with automatic key rotation capabilities.

Requirements

Create a ConfigManager class that:

  1. Accepts an initial API key during instantiation
  2. Provides a method to retrieve the current credential object
  3. Supports updating the API key without requiring reinstantiation of the manager
  4. Validates that API keys are non-empty strings before accepting them
  5. Throws descriptive errors when invalid keys are provided

The manager should be designed to work with Azure service clients that accept key-based credentials for authentication.

Implementation

@generates

API

/**
 * Manages API key credentials for Azure service clients with support for key rotation.
 */
export class ConfigManager {
  /**
   * Creates a new configuration manager with an initial API key.
   * @param initialKey - The initial API key to use for authentication
   * @throws Error if the initial key is invalid
   */
  constructor(initialKey: string);

  /**
   * Returns the current credential object that can be used with Azure service clients.
   * @returns The current credential object
   */
  getCredential(): unknown;

  /**
   * Rotates the API key to a new value.
   * @param newKey - The new API key to use
   * @throws Error if the new key is invalid
   */
  rotateKey(newKey: string): void;

  /**
   * Returns the current API key value.
   * @returns The current key as a string
   */
  getCurrentKey(): string;
}

Test Cases

  • It creates a manager with a valid initial API key @test
  • It throws an error when creating a manager with an empty key @test
  • It returns a credential object that has a key property @test
  • It successfully rotates the key to a new value @test
  • It reflects the updated key after rotation @test
  • It throws an error when rotating to an empty key @test

Dependencies { .dependencies }

@azure/core-auth { .dependency }

Provides authentication interfaces and credential implementations for Azure services.

Install with Tessl CLI

npx tessl i tessl/npm-azure--core-auth

tile.json