npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cypress-azure-keyvault

v2.0.0

Published

A cypress plugin to get data from Azure Keyvaults and set it in the enviroment.

Downloads

3,989

Readme

cypress-azure-keyvault

npm versionCodacy Badge

A custom Cypress plugin to access recover keys from Microsoft Azure Key Vaults.

Installation

npm install cypress-azure-keyvault --save-dev

or

yarn add cypress-azure-keyvault --dev

Configuring

Load the Module

Register the package's commands for use in your tests on your cypress/support/index.ts (or js file):

import "cypress-azure-keyvault";

And now you need to load the plugin into your cypress/plugins/index.js:

const { azureKeyvaultPlugin } = require("cypress-azure-keyvault");
module.exports = (on, config) => {
  // `on` is used to hook into various events Cypress emits
  // `config` is the resolved Cypress config
  return azureKeyvaultPlugin(on, config);
};

Configure access to Azure Key Vaults

In order to use the Azure Key Vault plugin, you must store your Azure access information as environment variables (either locally or/and define environment variables on azure).

You can also set it in a .env file (if you are using dotenv-cli package) or into your pipeline (as build variables).

You can find where to generate these values on the Azure Portal.

  export AZURE_CLIENT_ID="generated-app-ID"
  export AZURE_CLIENT_SECRET="random-password"
  export AZURE_TENANT_ID="tenant-ID"

Using the cy.getKeyvaultData()

Command interface

// command parameters
interface GetKeyvaultDataOptions {
  vault: string; // they keyvault name
  keys: string[]; // list of keys that you want to recover
  keyPrefix?: string; // a prefix for each key if the key vault is shared or if you prefix your keys by environment (optional)
  envSuffix?: string; // identifier for the environment (optional)
}

// command return
interface KeyVaultData {
  envSuffix: string;
  data: {
    [i: string]: string;
  };
}

Example

Without key prefix

describe("Example Azure Key Vault Flow", () => {
  let keysValues;
  before(() => {
    cy.getKeyvaultData({
      vault: 'myAppVault',
      keys: ['user', 'password']
    }).then(result => (keysValues = result.data));
  });

  it("should use key vault", () => {
    // my login tasks
    console.log(keysValues);
    // { user: "admin", password: "admin123!" }
  })

With key prefix

describe("Example Azure Key Vault Flow", () => {
  let keysValues;
  before(() => {
    cy.getKeyvaultData({
      vault: 'myAppVault',
      keys: ['user', 'password'],
      keyPrefix: "production"
    }).then(result => (keysValues = result.data));
  });

  it("should use key vault", () => {
    // my login tasks
    console.log(keysValues);
    // { production-user: "admin", production-password: "!QAWS@##was342" }
  })