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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@7edge-mangalore/authentication

v1.1.0

Published

Reusable authentication library for ZoodPay test automation

Readme

Authentication Library

A reusable, production-ready authentication library for the ZoodPay Distributor Web Application automation framework.

📁 Structure

test/authentication/
├── features/              # Gherkin feature files
│   └── login.feature     # Reusable login scenarios
├── step-definitions/     # Cucumber step definitions
│   └── authenticationSteps.cjs
├── services/             # Core authentication logic
│   └── AuthenticationService.cjs
├── config/               # User configurations
│   └── userConfig.cjs
└── README.md            # This file

🚀 Quick Start

Basic Usage in Feature Files

Feature: My Feature

  Background:
    Given Tom is in login page
    When Tom logs in as "masterDistributor" using "email" method
    And Tom verifies OTP with value "999999"
    Then Tom should be successfully logged in

  Scenario: Test something after login
    Given Tom is logged in
    When Tom performs some action
    Then Tom should see expected result

Using in Step Definitions

const { AuthenticationService } = require('../authentication/services/AuthenticationService.cjs');

// In your Before hook
Before(async function() {
  this.authService = new AuthenticationService(global.page);
});

// In your step definitions
When('Tom performs authenticated action', async function() {
  // Login if not already logged in
  if (!await this.authService.isLoggedIn()) {
    await this.authService.login({
      method: 'email',
      identifier: '[email protected]',
      password: 'password123',
      otp: '999999'
    });
  }
  
  // Continue with your test logic
});

📚 API Reference

AuthenticationService

Methods

login(credentials)

Complete login flow with OTP verification.

Parameters:

  • credentials.method (string): 'email' (primary method used)
  • credentials.identifier (string): Email address
  • credentials.password (string): User password
  • credentials.countryCode (string, optional): Country code (not used for email)
  • credentials.otp (string, optional): OTP value (default: from TEST_OTP env var or '999999')
  • credentials.skipOTP (boolean, optional): Skip OTP verification (default: false)
  • credentials.verifyDashboard (boolean, optional): Verify dashboard redirect (default: true)

Returns: Promise<Object> - Login result with user info

Example:

await authService.login({
  method: 'email',
  identifier: '[email protected]',
  password: 'password123',
  otp: '999999'
});
loginWithUserType(userType, config)

Login with pre-configured user credentials.

Parameters:

  • userType (string): User type from config (e.g., 'masterDistributor')
  • config (Object): User configuration object

Example:

const { getUserConfig } = require('./config/userConfig.cjs');
const config = getUserConfig('masterDistributor', 'email');
await authService.loginWithUserType('masterDistributor', { masterDistributor: config });
logout()

Logout from the application.

Example:

await authService.logout();
isLoggedIn()

Check if user is already logged in.

Returns: Promise<boolean>

Example:

const loggedIn = await authService.isLoggedIn();

🎯 Available Step Definitions

Navigation

  • Given Tom is in login page - Navigate to login page

Login Methods

  • When Tom logs in using {method} with identifier "{identifier}" and password "{password}"
  • When Tom logs in as "{userType}" using "{method}" method
  • When Tom logs in with default credentials

OTP Verification

  • When Tom verifies OTP with value "{otp}"
  • When Tom verifies OTP (uses default OTP: 999999)

Verification

  • Then Tom should be successfully logged in
  • Then Tom should see welcome message "{message}"
  • Then Tom should be redirected to the OTP verification page
  • Then Tom sees login by default opted as email

Logout

  • When Tom logs out

⚙️ Configuration

User Configuration

Edit config/userConfig.cjs to add or modify user credentials:

const userConfig = {
  masterDistributor: {
    email: {
      method: 'email',
      identifier: '[email protected]',
      password: 'password123',
      otp: '999999'
    }
  }
};

Environment Variables

You can override default credentials and OTP using environment variables:

export [email protected]
export TEST_USER_PASSWORD=password123
export TEST_OTP=123456  # Configurable OTP - overrides default '999999'
export SKIP_OTP=false

OTP Configuration:

  • The OTP is fully configurable via the TEST_OTP environment variable
  • If TEST_OTP is not set, it defaults to '999999' (test environment default)
  • OTP can be set per user in userConfig.cjs or globally via environment variable
  • When using step definitions, OTP will automatically use the configured value

🔒 Security Best Practices

  1. Never commit real credentials - Use environment variables or secure vaults
  2. Use test accounts only - Never use production credentials
  3. Rotate test credentials - Regularly update test account passwords
  4. Use secrets management - In CI/CD, use Azure Key Vault, AWS Secrets Manager, etc.

📝 Examples

Example 1: Simple Login in Feature File

Feature: Dashboard Tests

  Background:
    Given Tom is in login page
    When Tom logs in as "masterDistributor" using "email" method
    And Tom verifies OTP with value "999999"
    Then Tom should be successfully logged in

  Scenario: View dashboard
    Given Tom is logged in
    When Tom navigates to dashboard
    Then Tom should see dashboard elements

Example 2: Programmatic Login in Step Definitions

const { Given } = require('@cucumber/cucumber');
const { AuthenticationService } = require('../authentication/services/AuthenticationService.cjs');

Given('Tom is logged in', async function() {
  if (!this.authService) {
    this.authService = new AuthenticationService(global.page);
  }
  
  if (!await this.authService.isLoggedIn()) {
    await this.authService.login({
      method: 'email',
      identifier: '[email protected]',
      password: 'password123',
      otp: '999999'
    });
  }
});

Example 3: Using Different Login Methods

Scenario Outline: Login with different methods
  Given Tom is in login page
  When Tom logs in using <method> with identifier "<identifier>" and password "<password>"
  And Tom verifies OTP with value "999999"
  Then Tom should be successfully logged in

  Examples:
    | method | identifier           | password  |
    | email  | [email protected]     | pass123   |

🔄 Integration with Existing Tests

To use this library in your existing feature files:

  1. Import step definitions in your Cucumber configuration:

    // In cucumber.js or test runner
    require('./test/authentication/step-definitions/authenticationSteps.cjs');
  2. Use in Background of your feature files:

    Feature: My Feature
      Background:
        Given Tom is in login page
        When Tom logs in as "masterDistributor" using "email" method
        And Tom verifies OTP
        Then Tom should be successfully logged in
  3. Or use programmatically in your step definitions:

    const { AuthenticationService } = require('../authentication/services/AuthenticationService.cjs');

🧪 Testing the Library

Run the authentication feature file:

npx cucumber-js test/authentication/features/login.feature --require test/authentication/step-definitions

📋 Supported Login Methods

  1. Email Login - Login using email address and password (primary method)

OTP verification is required after initial credentials are submitted. OTP is configurable via TEST_OTP environment variable.

🐛 Troubleshooting

Issue: Step definition not found

Solution: Ensure step definitions are loaded in your Cucumber configuration:

require('./test/authentication/step-definitions/authenticationSteps.cjs');

Issue: Login fails

Solution:

  1. Check user credentials in config/userConfig.cjs
  2. Verify OTP value (default is 999999 for test environment)
  3. Check if login page URL is correct

Issue: OTP verification fails

Solution:

  1. Ensure OTP value matches test environment (usually 999999)
  2. Check OTP input field selectors
  3. Verify OTP page is loaded before entering OTP

🤝 Contributing

When adding new authentication methods or features:

  1. Update AuthenticationService.cjs with new methods
  2. Add corresponding step definitions in authenticationSteps.cjs
  3. Update userConfig.cjs with new user types if needed
  4. Add feature scenarios in login.feature
  5. Update this README with new functionality

📄 License

Internal use only - ZoodPay Distributor Web Application

👥 Maintainers

QA Automation Team


Last Updated: 2024 Version: 1.0.0