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

Added test from CLIAction #9992

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

Conversation

lifefire1
Copy link
Contributor

See JENKINS-70464

Testing done

I added a comprehensive set of unit tests for the CLIAction class, which include the following scenarios:

  • Test for the doCommand() method: Verifies that a 404 error is returned when an invalid command is requested.
  • Test for the doCommand() method with a valid parameter: Checks that the correct view dispatcher is called and forwarded when a valid command is provided.
  • Tests for WebSocket-related behavior:
    • Verifies that a WebSocket connection is not supported.
    • Checks the behavior when the origin header is invalid.
    • Ensures that WebSocket connections are allowed only if both conditions (WebSocket support and allowed origin) are met.
    • Verifies that a Forbidden response is returned when WebSocket connections are not allowed.

All tests were executed successfully on a local Jenkins instance.

Proposed changelog entries

  • Added unit tests for CLIAction class methods and WebSocket handling.
  • Improved test coverage for CLI commands and WebSocket connection handling.

Proposed upgrade guidelines

N/A


Pull Request Template

[tasklist]
### Submitter checklist
- [x] The Jira issue, if it exists, is well-described.
- [x] The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood.
- [x] There is automated testing or an explanation as to why this change has no tests.
- [x] New public classes, fields, and methods are annotated with @Restricted or have @since TODO Javadocs, as appropriate.
- [x] New deprecations are annotated with @Deprecated(since = "TODO") or @Deprecated(forRemoval = true, since = "TODO"), if applicable.
- [x] New or substantially changed JavaScript is not defined inline and does not call eval to ease future introduction of Content Security Policy (CSP) directives.
- [x] For dependency updates, there are links to external changelogs and, if possible, full differentials.
- [x] For new APIs and extension points, there is a link to at least one consumer.

@lifefire1
Copy link
Contributor Author

I might have misunderstood the task or made some mistakes, so I am always open to comments. I want to learn this project, so I decided to try it with tests.

Comment on lines +494 to +499
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-test-harness</artifactId>
<version>2353.ve3f890c6eea_f</version>
<scope>test</scope>
</dependency>
Copy link
Member

Choose a reason for hiding this comment

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

Remove and move the test to test/src/test/

@daniel-beck daniel-beck added the skip-changelog Should not be shown in the changelog label Nov 19, 2024
@daniel-beck
Copy link
Member

See JENKINS-70464

The ticket seems unrelated to this PR, could you explain how they relate?

@lifefire1
Copy link
Contributor Author

Perhaps you are right and I really indicated the wrong ticket. I wanted to improve test coverage as a first step

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Should not be shown in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants