Skip to content
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

ci: add test for windows #1029

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

bjohansebas
Copy link
Member

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discovered that the error is in this file

Copy link
Member

@UlisesGascon UlisesGascon Mar 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can make it work with some tweaks:

#!/usr/bin/env bash

set -e

# Detect OS
OS="$(uname -s)"

# Define file paths
KEY_PATH="./test/fixtures/server.key"
CERT_PATH="./test/fixtures/server.crt"

# Generate the certificate
if [[ "$OS" == "Linux" || "$OS" == "Darwin" || "$OS" == "MINGW"* || "$OS" == "MSYS"* || "$OS" == "CYGWIN"* ]]; then
    echo "Running on OS: $OS"
    openssl req -x509 -nodes -newkey rsa:2048 \
    -keyout "$KEY_PATH" \
    -out "$CERT_PATH" \
    -days 3650 \
    -subj "/C=US/ST=Illinois/L=Chicago/O=node-express-session/CN=express-session.local"
else
    echo "Unsupported OS: $OS"
    exit 1
fi

echo "Certificate generated successfully at: $CERT_PATH"

So far seems like the -subj argument is the problem on the win environment (ref):

++ uname
+ OS=MINGW64_NT-10.0-20348
+ '[' MINGW64_NT-10.0-20348 = Linux ']'
+ '[' MINGW64_NT-10.0-20348 = Darwin ']'
+ openssl req -x509 -nodes -newkey rsa:2048 -keyout ./test/fixtures/server.key -out ./test/fixtures/server.crt -days 3650 -subj //C=US//ST=Illinois//L=Chicago//O=node-express-session//CN=express-session.local
......+..+.+..+...+....+.....+..................+......+....+..+.+..+...............+...+...+....+...+++++++++++++++++++++++++++++++++++++++*.+..+.......+.....+.+......+..............+......+++++++++++++++++++++++++++++++++++++++*..+..........+...+..............................+......+.....+....+........+.......+..+................+..+.+......+.....+.+..+...+...+......+......+..........+..+..................+....+...+........+..........+..+...............+.+......+.....+.+..+............+.+...+..+............................+.....+....+.....+...+........................+...+.+..+...+....+..+..........+.........+.........+.....+...+....+...........+....+......+..+.............+...............+..+...........................+.+...+.....++++++
.+.+........+......+.........+......+....+.........+..+...+................+.........+.....+......+....+...........+.+.....+.+...+..+...+............+...+.+......+++++++++++++++++++++++++++++++++++++++*..+....+..............+.+.....+....+.........+.....+.+..+.......+...........+....+...+.....+...+.+.........+...............+.....+.+...+..+................+........+.........+...+....+........+++++++++++++++++++++++++++++++++++++++*..+.....+.........+.+......+...+...+..+.............+............+.....+.+...............+.....+.+........+.+.....+....+..+..................+.+..+....+...+..+.+..+...+....+.....+....+..+........................................+...+...........+.+..+.....................+......+...+......+.+.....+.+...+..............+...............+.+.....+.+......+...+...............+.....+......+.........+................+.....+..................+.+..+....+...+.....+.+..+...............+....+.....+...+.......+..............+.+......++++++
-----
req warning: Skipping unknown subject name attribute "/C"
req warning: Skipping unknown subject name attribute "/ST"
req warning: Skipping unknown subject name attribute "/L"
req warning: Skipping unknown subject name attribute "/O"
req warning: Skipping unknown subject name attribute "/CN"

-subj "/C=US/ST=Illinois/L=Chicago/O=node-express-session/CN=express-session.local"
OS=$(uname)

if [ "$OS" = "Linux" ] || [ "$OS" = "Darwin" ]; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to reverse this if? I mean, should we check that if the OS is Windows, then use the alternative command.

The CI currently tests in windows and linux, but BSD and other similar systems are supported as far as I know.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy switch case could be:

case "$(uname)" in
  MINGW*) ... ;;
  *) ... ;;
esac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants