-
Notifications
You must be signed in to change notification settings - Fork 300
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
Development
: Analyze REST calls and endpoints
#8771
Development
: Analyze REST calls and endpoints
#8771
Conversation
…nt-sided-REST-api' into feature/development/parsing-client-sided-REST-api
…nt-sided-REST-api' into feature/development/parsing-client-sided-REST-api
… feature/development/analyze-RESTcalls-and-Endpoints
Development
: analyze REST-calls and endpoints
…nt-sided-REST-api' into feature/development/parsing-client-sided-REST-api
… feature/development/analyze-RESTcalls-and-Endpoints
… feature/development/analyze-RESTcalls-and-Endpoints # Conflicts: # supporting_scripts/analysis-of-endpoint-connections/src/main/typeScript/AnalysisOfEndpointConnectionsClient.ts
…ilter and print results.
…ilter and print results.
…nt-sided-REST-api' into feature/development/parsing-client-sided-REST-api
...ysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/EndpointAnalyzer.java
Outdated
Show resolved
Hide resolved
...ysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/EndpointAnalyzer.java
Show resolved
Hide resolved
...ysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/EndpointAnalyzer.java
Outdated
Show resolved
Hide resolved
...alysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/EndpointParser.java
Outdated
Show resolved
Hide resolved
...alysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/EndpointParser.java
Outdated
Show resolved
Hide resolved
...ysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/RestCallAnalyzer.java
Show resolved
Hide resolved
…ava/de/tum/cit/endpointanalysis/EndpointAnalyzer.java Co-authored-by: Johannes Stöhr <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
...alysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/EndpointParser.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after changes, reapprove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve code, thanks for addressing the change requests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code lgtm, github workflow seems to be working as expected!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Further follow-up: Check how many public methods can be made (package-)private.
Aside from that, the code looks good. Tested on https://github.com/ls1intum/Artemis/pull/8771/checks.
...s-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/RestCallInformation.java
Show resolved
Hide resolved
...-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/RestCallFileInformation.java
Show resolved
Hide resolved
...s-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/EndpointInformation.java
Show resolved
Hide resolved
...ysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/EndpointAnalyzer.java
Show resolved
Hide resolved
...ysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/RestCallAnalyzer.java
Show resolved
Hide resolved
...ysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/RestCallAnalyzer.java
Show resolved
Hide resolved
...ysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/EndpointAnalyzer.java
Show resolved
Hide resolved
...ysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/RestCallAnalyzer.java
Show resolved
Hide resolved
...alysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/EndpointParser.java
Show resolved
Hide resolved
Development
: analyze REST-calls and endpointsDevelopment
: Analyze REST calls and endpoints
Checklist
General
Context
Building on the functionality introduced in the previous PRs, where we successfully parsed information regarding changed server endpoints and client-sided REST api calls, the proposed feature aims to take the parsing a step further. The new feature will introduce the comparison and analysis of client-sided REST calls against server-sided endpoints. By cross-referencing the HTTP methods and URLs used in client requests with the server endpoints, we can identify mismatches, inconsistencies, and potential errors in the API interactions between the client and server. This comparison will enhance our ability to ensure that the client and server components are correctly aligned, thereby improving the reliability and robustness of the application.
Problem
The problem tackled in this issue is the potential for discrepancies and misalignments between client-sided REST calls and server-sided endpoints, which can lead to broken functionality and increased debugging time. Currently, developers must manually ensure that the client and server communicate correctly. Manual verification is not only labor-intensive but also susceptible to oversights, leading to potential bugs and degraded user experience. Without automated verification, mismatches in URLs, HTTP methods, and expected data formats can easily slip through code reviews and testing phases, causing features to fail in production. This issue addresses the need for an automated solution to compare and analyze client-sided REST calls against server-sided endpoints, ensuring consistency and correctness across the application and reducing the risk of integration errors.
Motivation
The motivation behind this feature is to enhance the robustness and reliability of the Artemis application by automating the verification of API interactions between client and server. Ensuring that client-sided REST calls match the server-side endpoints is crucial for seamless functionality, user satisfaction, and overall system integrity. By implementing automated comparison and analysis, we can proactively identify and resolve discrepancies early in the development process, reducing the time spent on debugging and improving development efficiency. This feature will empower developers with more accurate insights, streamline the code review process, and ultimately contribute to a more stable and reliable application.
Requirements Engineering
Existing (Problematic) Solution / System
Currently, the existing solution comprises two separate GitHub Actions developed in previous PRs. The first action parses information related to changed server endpoints, providing insights into modifications on the server side. The second action extends this functionality by parsing client-sided REST calls, extracting details such as HTTP methods and URLs used in client requests. However, these actions operate independently and do not offer a mechanism for cross-referencing or comparing client-side REST calls with server-side endpoints. As a result, while they provide valuable information individually, they do not address the need for ensuring consistency and alignment between the client and server API interactions, which is critical for maintaining application integrity.
Proposed System
The proposed system is an integrated solution that automates the verification of API interactions between the client and server, ensuring that client-sided REST calls are correctly aligned with server-side endpoints. This system would significantly reduce the manual effort required for verifying API interactions, enhance the accuracy and reliability of client-server communication, and ultimately lead to higher code quality and more stable applications. To verify the API interactions, the system identifies REST calls and endpoints in modified files and checks if there are endpoints matching the REST calls and REST calls using the endpoints. If there is no endpoint matching a specific REST call, the system will identify it and output a warning to the console. If an Endpoint is not used by any REST call of the Client, the system will print a warning, too.
Requirements
Functional Requirements
Non-Functional Requirements
Analysis
Analysis Object Model
This model depicts an abstract structure of how REST methods (e.g., GET, POST, PUT, DELETE) are integrated into a software system. To be able to call a REST method, there needs to be a call to a REST endpoint and the REST endpoint itself. A REST method is called by the client. The call happens within a Java method call. The respective REST endpoint is located on the server. Each endpoint is contained in its own Java method.
Dynamic Behavior
The following model illustrates the process of parsing and analyzing client-sided REST calls and server-sided endpoints within a software project, focusing on files modified in a PR. First, the system identifies all files that have been modified in the current pull request. Once these files are identified, the system proceeds to parse both server-sided and client-sided endpoints separately.
For server-sided endpoints, the system searches for methods within the server files. Upon finding methods, the system checks whether any of these methods serve as server endpoints. If a method is identified as an endpoint, the relevant information, such as the HTTP method and URL, is parsed and stored for further analysis.
Similarly, the system handles client-sided endpoints. The system looks for methods within client files. If methods are found, the system then determines whether any of these methods contain REST calls. If a method containing a REST call is found, the system parses the relevant information, such as the HTTP method and URL, and stores it for further analysis.
After parsing both client-sided and server-sided files, the system checks if an endpoint is accessed by one ore more REST calls. If matching REST calls are found, the REST calls and the endpoint will be printed to the GitHub action. If there is no matching REST call found, a warning containing the unused endpoint will be printed to the actions output. Similarly, the system will check for every REST call, if there is exactly one matching endpoint on the server. If so, the system will print the REST call and the corresponding endpoint to its output. If there are more ore less then one matching endpoint, the software will print another warning containing the REST call and the duplicate or missing endpoints.
The software detects any inconsistencies or mismatches between the client-sided REST calls and the server-sided endpoints. This thorough analysis ensures that the client and server components are synchronized, thereby improving the overall reliability and usability of the system.
System Architecture
Subsystem Decomposition
The system is split into four distinct subsystems. The first subsystem identifies all files that are modified within a PR.
The second subsystem parses the modified server files regarding their endpoints. It extracts and stores relevant information like the endpoint's path, name, and the HTTP method it is using.
The third subsystem parses the modified client files regarding the REST calls used. It stores relevant information like the REST call's path, the HTTP method used, and the function's name.
The fourth subsystem analyzes and compares the data regarding server endpoints and client REST calls, gathered by the second and third subsystem. The system identifies issues like mismatches in client- and server-sided URLs and missing endpoints on the server. It prints a concise summary of its findings, improving and simplifying the review process.
This decomposition into specialized subsystems facilitates a modular approach, making the system easier to develop, maintain, and extend.
Persistent Data Management
The findings by the second and third subsystems are to be stored in
.json
files within the GitHub action. The fourth subsystem can then read the information from the files and process and analyze it.The
.json
file containing the information parsed from the client files will look like this:The
.json
file containing the information parsed from the server files will look like this:Steps for Testing
analyze endpoints
and decide if it is comprehensive and concise, or if there are things that need to be improvedanalyze rest calls
and decide if it is comprehensive and concise, or if there are things that need to be improvedTestserver States
Note
These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Review Progress
Performance Review
Code Review
Test Coverage
unchanged
Screenshots
Summary by CodeRabbit
Summary by CodeRabbit
New Features
EndpointAnalyzer
,RestCallAnalyzer
, andRestCallInformation
.EndpointInformation
andRestCallInformation
to enhance data management for endpoints and REST calls.Improvements
Bug Fixes