Skip to content

Docker: Update basic auth headers in util scripts #2779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged

Conversation

VietND96
Copy link
Member

@VietND96 VietND96 commented Apr 10, 2025

User description

Thanks for contributing to the Docker-Selenium project!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines, applied for this repository.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Enhancement, Bug fix


Description

  • Improved handling of basic authentication headers in utility scripts.

    • Added conditional checks for username and password presence.
    • Standardized the Authorization header format across scripts.
  • Replaced hardcoded Authorization header with dynamic variable usage.

  • Enhanced error handling and logging for authentication-related operations.

  • Updated scripts to ensure compatibility with authentication changes.


Changes walkthrough 📝

Relevant files
Enhancement
9 files
check-grid.sh
Conditional handling for basic auth and header standardization
+5/-2     
validate_endpoint.sh
Improved basic auth handling and header usage                       
+6/-3     
video.sh
Standardized basic auth header and added conditional checks
+6/-3     
video_graphQLQuery.sh
Added conditional checks for basic auth and updated header usage
+5/-2     
distributorProbe.sh
Enhanced basic auth handling and header standardization   
+9/-6     
nodeGridUrl.sh
Conditional basic auth handling and header improvements   
+5/-2     
nodePreStop.sh
Improved basic auth handling and header usage                       
+5/-2     
nodeProbe.sh
Enhanced basic auth handling and error logging                     
+5/-2     
routerProbe.sh
Standardized basic auth header and added conditional checks
+5/-2     
Tests
1 files
bootstrap.sh
Updated basic auth handling and header usage in tests       
+2/-1     

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Missing Curl Command

    The else branch of the if-statement is missing the curl command implementation, which would cause the endpoint_checks variable to be unset when graphql_endpoint is not true.

    else
      endpoint_checks=$(curl --noproxy "*" -H "${BASIC_AUTH}" -m ${max_time} -s -k -o /dev/null -w "%{http_code}" "${endpoint}")
    fi
    Conditional Check

    The conditional check for environment variables is missing the quotes around the variable names, which could lead to syntax errors if the variables are unset.

    if [ -n ${SELENIUM_GRID_USERNAME} ] && [ -n ${SELENIUM_GRID_PASSWORD} ]; then
      BASIC_AUTH="$(echo -en "${SELENIUM_GRID_USERNAME}:${SELENIUM_GRID_PASSWORD}" | base64 -w0)"

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Handle empty auth header

    The curl command will fail when basic auth credentials are not provided because
    ${BASIC_AUTH} will be empty but still used with the -H flag. Add a condition to
    only include the header when credentials are available.

    Base/check-grid.sh [33]

    -curl -skSL --noproxy "*" -H "${BASIC_AUTH}" ${SE_SERVER_PROTOCOL:-"http"}://${HOST}:${PORT}/wd/hub/status | jq -r '.value.ready' | grep -q "true" || exit 1
    +if [ -n "${BASIC_AUTH}" ]; then
    +  curl -skSL --noproxy "*" -H "${BASIC_AUTH}" ${SE_SERVER_PROTOCOL:-"http"}://${HOST}:${PORT}/wd/hub/status | jq -r '.value.ready' | grep -q "true" || exit 1
    +else
    +  curl -skSL --noproxy "*" ${SE_SERVER_PROTOCOL:-"http"}://${HOST}:${PORT}/wd/hub/status | jq -r '.value.ready' | grep -q "true" || exit 1
    +fi
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    __

    Why: This suggestion addresses a critical issue where the curl command would fail when basic auth credentials are not provided, as the empty ${BASIC_AUTH} variable would still be used with the -H flag. The fix properly handles both authenticated and non-authenticated scenarios.

    High
    • More

    @VietND96 VietND96 merged commit cb78635 into trunk Apr 11, 2025
    28 checks passed
    @VietND96 VietND96 deleted the basic-auth branch April 11, 2025 01:54
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant