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

Use absolute path to find credential files in unit tests #340

Merged

Conversation

BewareMyPower
Copy link
Contributor

Fixes #339

Motivation

Currently the relative path is used in unit tests to specify the token file (.test-token.txt) and the credential directory (./test-conf). If we don't run the pulsar-tests binary in a subdirectory, it won't be able to read these files.

Modifications

Add the macro -DTOKEN_PATH="..." -DTEST_CONF_DIR="..." to specify absolute paths according to the PROJECT_SOURCE_DIR, which is defined by CMake as the absolute path of the project directory.

Verifications

cmake -B build
cmake --build build -j8
# Run the test in project directory
./build/tests/pulsar-tests --gtest_filter='AuthPlugin*:*testRSAEncryption:*testEncryptionFailure:*DecryptionFailedMessages'
# Run the test in a subdirectory
cd build
./tests/pulsar-tests --gtest_filter='AuthPlugin*:*testRSAEncryption:*testEncryptionFailure:*DecryptionFailedMessages'

Fixes apache#339

### Motivation

Currently the relative path is used in unit tests to specify the token
file (`.test-token.txt`) and the credential directory (`./test-conf`).
If we don't run the `pulsar-tests` binary in a subdirectory, it won't
be able to read these files.

### Modifications

Add the macro `-DTOKEN_PATH="..." -DTEST_CONF_DIR="..."` to specify
absolute paths according to the `PROJECT_SOURCE_DIR`, which is defined
by CMake as the absolute path of the project directory.

### Verifications

```bash
cmake -B build
cmake --build build -j8
# Run the test in project directory
./build/tests/pulsar-tests --gtest_filter='AuthPlugin*:*testRSAEncryption:*testEncryptionFailure:*DecryptionFailedMessages'
# Run the test in a subdirectory
cd build
./tests/pulsar-tests --gtest_filter='AuthPlugin*:*testRSAEncryption:*testEncryptionFailure:*DecryptionFailedMessages'
```
@BewareMyPower BewareMyPower merged commit 47fb809 into apache:main Nov 9, 2023
11 checks passed
@BewareMyPower BewareMyPower deleted the bewaremypower/test-absolute-path branch November 9, 2023 07:19
BewareMyPower added a commit to BewareMyPower/pulsar-client-python that referenced this pull request Nov 16, 2023
BewareMyPower added a commit to apache/pulsar-client-python that referenced this pull request Nov 16, 2023
@BewareMyPower BewareMyPower modified the milestones: 3.5.0, 3.4.1 Nov 16, 2023
BewareMyPower added a commit that referenced this pull request Nov 17, 2023
Fixes #339

### Motivation

Currently the relative path is used in unit tests to specify the token
file (`.test-token.txt`) and the credential directory (`./test-conf`).
If we don't run the `pulsar-tests` binary in a subdirectory, it won't
be able to read these files.

### Modifications

Add the macro `-DTOKEN_PATH="..." -DTEST_CONF_DIR="..."` to specify
absolute paths according to the `PROJECT_SOURCE_DIR`, which is defined
by CMake as the absolute path of the project directory.

### Verifications

```bash
cmake -B build
cmake --build build -j8
# Run the test in project directory
./build/tests/pulsar-tests --gtest_filter='AuthPlugin*:*testRSAEncryption:*testEncryptionFailure:*DecryptionFailedMessages'
# Run the test in a subdirectory
cd build
./tests/pulsar-tests --gtest_filter='AuthPlugin*:*testRSAEncryption:*testEncryptionFailure:*DecryptionFailedMessages'
```

(cherry picked from commit 47fb809)
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.

[Test] AuthPluginToken.testToken and AuthPluginToken.testTokenWithHttpUrl get failed
2 participants