├── .github
└── workflows
│ └── main.yml
├── .gitignore
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── doc
└── diagram
│ ├── architecture.diagram.svg
│ ├── assertion.diagram.svg
│ ├── deploy.diagram.svg
│ ├── general.diagram.svg
│ ├── integration.diagram.svg
│ ├── lib.xml
│ ├── overview.diagram.svg
│ ├── problem.diagram.svg
│ ├── schema1
│ ├── setup.diagram.svg
│ ├── solution.diagram.svg
│ └── usecase.diagram.svg
├── pom.xml
└── src
├── main
└── java
│ └── org
│ └── usf
│ └── assertapi
│ └── core
│ ├── AbstractModelTransformer.java
│ ├── ApiAssertionError.java
│ ├── ApiAssertionFactory.java
│ ├── ApiAssertionRuntimeException.java
│ ├── ApiExecutor.java
│ ├── ApiRequest.java
│ ├── BasicClientAuthenticator.java
│ ├── BearerClientAuthenticator.java
│ ├── ClientAuthenticator.java
│ ├── ClientResponseWrapper.java
│ ├── ComparisonResult.java
│ ├── ComparisonStage.java
│ ├── ComparisonStatus.java
│ ├── ConnectedAssertionExecutor.java
│ ├── CsvDataComparator.java
│ ├── DataMapper.java
│ ├── DataTransformer.java
│ ├── DisconnectedAssertionExecutor.java
│ ├── ExecutionConfig.java
│ ├── ExecutionInfo.java
│ ├── HeadersComparator.java
│ ├── HttpRequest.java
│ ├── JsonDataComparator.java
│ ├── JsonDataMapper.java
│ ├── JsonKeyMapper.java
│ ├── JsonPathFilter.java
│ ├── JsonPathMover.java
│ ├── ModelComparator.java
│ ├── ModelTransformer.java
│ ├── PolymorphicType.java
│ ├── ReleaseTarget.java
│ ├── ResponseComparator.java
│ ├── ResponseComparatorProxy.java
│ ├── RestTemplateBuilder.java
│ ├── RootUriTemplateHandler.java
│ ├── RuntimeEnvironement.java
│ ├── SequentialFuture.java
│ ├── ServerAuth.java
│ ├── ServerConfig.java
│ ├── StaticResponse.java
│ ├── StringBytesDeserializer.java
│ ├── StringBytesSerializer.java
│ ├── TemporalShift.java
│ ├── Utils.java
│ └── exception
│ └── TransformerException.java
└── test
├── java
└── org
│ └── usf
│ └── assertapi
│ └── core
│ ├── AbstractModelTransformerTest.java
│ ├── BasicClientAuthenticatorTest.java
│ ├── BearerClientAuthenticatorTest.java
│ ├── DataMapperTest.java
│ ├── ExecutionConfigTest.java
│ ├── ExecutionInfoTest.java
│ ├── HttpRequestTest.java
│ ├── JsonDataMapperTest.java
│ ├── JsonDefaultValueMapperTest.java
│ ├── JsonKeyMapperTest.java
│ ├── JsonPathFilterTest.java
│ ├── JsonPathMoverTest.java
│ ├── ResponseComparatorProxyTest.java
│ ├── ResponseComparatorTest.java
│ ├── RuntimeEnvironementTest.java
│ ├── SequentialFutureTest.java
│ ├── ServerConfigTest.java
│ ├── StaticResponseTest.java
│ ├── TemporalShiftTest.java
│ └── UtilsTest.java
└── resources
└── org
└── usf
└── assertapi
└── core
├── request
└── http
│ ├── case1
│ └── request.json
│ ├── case2
│ └── request.json
│ ├── case3
│ └── request.json
│ └── case4
│ └── request.json
└── transformer
├── data
└── data-mapper
│ ├── case1
│ └── tests.json
│ ├── case2
│ └── tests.json
│ ├── case3
│ └── tests.json
│ └── transformer.json
└── json
├── data-mapper
├── case1.1
│ ├── expected.json
│ └── transformer.json
├── case1
│ ├── expected.json
│ └── transformer.json
├── case2
│ ├── expected.json
│ └── transformer.json
└── origin.json
├── key-mapper
├── case1
│ ├── expected.json
│ └── transformer.json
├── case2
│ ├── expected.json
│ └── transformer.json
├── case3
│ ├── expected.json
│ └── transformer.json
├── case4
│ ├── expected.json
│ └── transformer.json
└── origin.json
├── path-filter
├── case1
│ ├── expected.json
│ └── transformer.json
├── case2
│ ├── expected.json
│ └── transformer.json
├── case3
│ ├── expected.json
│ └── transformer.json
├── case4
│ ├── expected.json
│ └── transformer.json
└── origin.json
├── path-mover
├── case1.1
│ ├── expected.json
│ └── transformer.json
├── case1.2
│ ├── expected.json
│ └── transformer.json
├── case1.3
│ ├── expected.json
│ └── transformer.json
├── case1.4
│ ├── expected.json
│ └── transformer.json
├── case1.5
│ ├── expected.json
│ └── transformer.json
├── case2.1
│ ├── expected.json
│ └── transformer.json
├── case2.2
│ ├── expected.json
│ └── transformer.json
├── case2.3
│ ├── expected.json
│ └── transformer.json
├── case2.4
│ ├── exception.json
│ └── transformer.json
├── case3.1
│ ├── expected.json
│ └── transformer.json
├── case3.2
│ ├── expected.json
│ └── transformer.json
├── case3.3
│ ├── expected.json
│ └── transformer.json
├── case3.4
│ ├── exception.json
│ └── transformer.json
├── case4.1
│ ├── expected.json
│ └── transformer.json
├── case4.2
│ ├── expected.json
│ └── transformer.json
├── case4.3
│ ├── expected.json
│ └── transformer.json
├── case4.4
│ ├── exception.json
│ └── transformer.json
├── case4.5
│ ├── exception.json
│ └── transformer.json
├── case4.6
│ ├── exception.json
│ └── transformer.json
├── case4.7
│ ├── exception.json
│ └── transformer.json
├── case4.8
│ ├── exception.json
│ └── transformer.json
└── origin.json
└── value-mapper
├── case1.1
├── expected.json
└── transformer.json
├── case1.2
├── expected.json
└── transformer.json
├── case1.3
├── expected.json
└── transformer.json
├── case1.4
├── expected.json
└── transformer.json
├── case1.5
├── expected.json
└── transformer.json
├── case2.1
├── expected.json
└── transformer.json
├── case2.2
├── expected.json
└── transformer.json
├── case2.3
├── expected.json
└── transformer.json
├── case2.4
├── expected.json
└── transformer.json
└── origin.json
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3 |
4 | # This workflow uses actions that are not certified by GitHub.
5 | # They are provided by a third-party and are governed by
6 | # separate terms of service, privacy policy, and support
7 | # documentation.
8 |
9 | name: CI/CD
10 | on:
11 | pull_request:
12 | types: [opened, synchronize, reopened]
13 | branches: [ "main" ]
14 | paths-ignore: [ "README.md", "doc/**" ]
15 | push:
16 | branches: [ "main", "develop" ]
17 | paths-ignore: [ "README.md", "doc/**" ]
18 | jobs:
19 | build:
20 | runs-on: ubuntu-latest
21 | steps:
22 | - uses: actions/checkout@v3
23 | - name: Set up JDK 11
24 | uses: actions/setup-java@v3
25 | with:
26 | java-version: '11'
27 | distribution: 'temurin'
28 | - name: Build & Scan Project
29 | env:
30 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
31 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
32 | run: mvn --batch-mode --no-transfer-progress verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=oneteme_${{ github.event.repository.name }}
33 | deploy:
34 | needs: build
35 | if: github.event_name == 'push'
36 | runs-on: ubuntu-latest
37 | steps:
38 | - name: Install gpg secret key
39 | if: github.ref == 'refs/heads/main'
40 | run: |
41 | cat <(echo -e "${{ secrets.MAVEN_GPG_PRIVATE_KEY }}") | gpg --batch --import
42 | gpg --list-secret-keys --keyid-format LONG
43 | - uses: actions/checkout@v3
44 | - name: Set up JDK 11
45 | uses: actions/setup-java@v3
46 | with:
47 | java-version: '11'
48 | distribution: 'temurin'
49 | server-id: ossrh
50 | server-username: MAVEN_USERNAME
51 | server-password: MAVEN_PASSWORD
52 | - name: Extract Maven version
53 | id: projectVersion
54 | run: echo "version=$(mvn org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate -DforceStdout -Dexpression=project.version -q)" >>$GITHUB_OUTPUT
55 | - name: Publish SNAPSHOT
56 | if: endsWith(steps.projectVersion.outputs.version, '-SNAPSHOT')
57 | env:
58 | MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
59 | MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
60 | run: mvn --no-transfer-progress --batch-mode clean deploy
61 | - name: Publish RELEASE
62 | if: ${{ github.ref == 'refs/heads/main' && !endsWith(steps.projectVersion.outputs.version, '-SNAPSHOT') }}
63 | env:
64 | MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
65 | MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
66 | run: mvn --no-transfer-progress --batch-mode -Dgpg.passphrase=${{ secrets.MAVEN_GPG_PASSPHRASE }} -Pdeploy clean deploy
67 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 | .sts4-cache
12 |
13 | ### IntelliJ IDEA ###
14 | .idea
15 | *.iws
16 | *.iml
17 | *.ipr
18 |
19 | ### NetBeans ###
20 | /nbproject/private/
21 | /build/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
26 |
27 | ### NOVA
28 | asm-log/
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | usf.alami@gmail.com.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # assertapi-core
3 |
4 | AssertAPI is a Java library designed for testing RESTful APIs. It allows developers to easily write and automate tests, while also enabling collaboration with QA teams.
5 |
6 | ### Features
7 | Here are some of the key features of AssertAPI:
8 |
9 | - Tests can be defined in JSON format, making it easy to write and maintain test cases.
10 | - Supports testing of APIs using different authentication methods, such as BASIC and BEARER.
11 | - Can compare API responses in different formats, including JSON, XML, TXT, CSV, and more.
12 | - Supports testing of API migrations between different versions.
13 | - Developers can extend AssertAPI's functionality by injecting their own classes for authentication, comparison, and response transformation.
14 | - Tests can be executed automatically before each deployment to production.
15 | - AssertAPI promotes collaboration between developers and QA teams.
16 |
17 | ...
18 |
19 | ## Status
20 | [](https://github.com/oneteme/assertapi-core/actions/workflows/main.yml)
21 | [](https://sonarcloud.io/summary/new_code?id=oneteme_assertapi-core)
22 |
23 | ## Problem
24 |
25 | text..
26 |
27 | 
28 |
29 | ## Solution
30 |
31 | text..
32 |
33 | 
34 |
35 | ## Integration
36 |
37 | text..
38 |
39 | 
40 |
41 | ## Usecase
42 |
43 | text..
44 |
45 | 
46 |
47 | ## Overview
48 |
49 | text..
50 |
51 | 
52 |
53 | ## Setup
54 |
55 | text..
56 |
57 | 
58 |
59 | ## Deploy
60 |
61 | text..
62 |
63 | 
64 |
65 | ## Assertion
66 |
67 | text..
68 |
69 | 
70 |
71 | ## Architecture
72 |
73 | text..
74 |
75 | 
76 |
77 | ### Extensibility
78 |
79 | Developers can extend the functionality of AssertAPI by injecting their own classes to override authentication, comparison, and transformation of responses before comparison. This makes AssertAPI highly customizable and flexible to fit your specific needs.
80 |
81 | ## MAVEN Integration
82 |
83 | ```xml
84 |
85 | io.github.oneteme.assertapi
86 | assertapi-core
87 | 0.0.1-SNAPSHOT
88 |
89 | ```
90 |
91 | ## Usage
92 |
93 | ```java
94 | var assertion = new ApiAssertionFactory()
95 | .comparing(stableRelease, latestRelease) //run api on stable and latest server
96 | .using(responseComparator) // ResponseComparator by default
97 | .build()
98 | .assertApi(api); // compare results each other
99 | ```
100 |
101 | ### Handle assertion result
102 |
103 | ```java
104 | var assertion = new ApiAssertionFactory()
105 | .comparing(stableRelease, latestRelease)
106 | .using(responseComparator)
107 | .trace((api, res)-> log.debug("testing : {} => {}", api, res)) //log api compare result
108 | .build()
109 | .assertApi(api);
110 | ```
111 |
112 | ### Register custom Client Authenticator
113 |
114 | ```java
115 | var assertion = new ApiAssertionFactory()
116 | .regiter("BASIC_TOKEN", customTokenAuthenticator) // customTokenAuthenticator must implements ClientAuthenticator
117 | .comparing(stableRelease, latestRelease)
118 | .using(responseComparator)
119 | .build()
120 | .assertApi(api);
121 | ```
122 |
123 | ### Comparison Stages
124 |
125 |
126 | 1. ELAPSED_TIME
127 | 2. HTTP_CODE
128 | 3. CONTENT_TYPE
129 | 4. HEADER_CONTENT
130 | 5. RESPONSE_CONTENT
131 |
132 |
133 | ### ApiRequest
134 | | Field | Description | default |
135 | | ---------------- | ----------------------- | ------- |
136 | | uri | HTTP uri | |
137 | | method | HTTP method | GET |
138 | | headers | HTTP headers | N/A |
139 | | body | HTTP body | N/A |
140 | | acceptableStatus | HTTP expected status | [200] |
141 | | name | API name | N/A |
142 | | version | API version | N/A |
143 | | description | API description | N/A |
144 | | contentComparator | Content comparator | N/A |
145 | | executionConfig | Execution configuration | N/A |
146 |
147 | ### ContentComparator
148 | | Field | Description | default |
149 | | ---------------- | ----------------------- | ------- |
150 | | type | Content comparator type | N/A |
151 | | transformers | Content transformers | N/A |
152 |
153 | ### ExecutionConfig
154 | | Field | Description | default |
155 | | ---------------- | ----------------------- | ------- |
156 | | parallel | API Parallel execution | true |
157 | | enabled | API Assertion enabled | true |
158 |
--------------------------------------------------------------------------------
/doc/diagram/lib.xml:
--------------------------------------------------------------------------------
1 | [{"data":"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGlkPSJpY29uIiB2aWV3Qm94PSIwIDAgMzIgMzIiIGhlaWdodD0iNjRweCIgd2lkdGg9IjY0cHgiIGZpbGw9IiM1MDUwNTAiPiYjeGE7JiN4YTs8ZyBzdHJva2Utd2lkdGg9IjAiIGlkPSJTVkdSZXBvX2JnQ2FycmllciIvPiYjeGE7JiN4YTs8ZyBzdHJva2UtbGluZWpvaW49InJvdW5kIiBzdHJva2UtbGluZWNhcD0icm91bmQiIGlkPSJTVkdSZXBvX3RyYWNlckNhcnJpZXIiLz4mI3hhOyYjeGE7PGcgaWQ9IlNWR1JlcG9faWNvbkNhcnJpZXIiPiYjeGE7JiN4YTs8ZGVmcz4mI3hhOyYjeGE7PHN0eWxlPi5jbHMtMXtmaWxsOm5vbmU7fTwvc3R5bGU+JiN4YTsmI3hhOzwvZGVmcz4mI3hhOyYjeGE7PHRpdGxlPmNvbXBhcmU8L3RpdGxlPiYjeGE7JiN4YTs8cGF0aCB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwKSIgZD0iTTI4LDZIMThWNGEyLDIsMCwwLDAtMi0ySDRBMiwyLDAsMCwwLDIsNFYyNGEyLDIsMCwwLDAsMiwySDE0djJhMiwyLDAsMCwwLDIsMkgyOGEyLDIsMCwwLDAsMi0yVjhBMiwyLDAsMCwwLDI4LDZaTTQsMTVoNi4xN0w3LjU5LDE3LjU5LDksMTlsNS01TDksOSw3LjU5LDEwLjQxLDEwLjE3LDEzSDRWNEgxNlYyNEg0Wk0xNiwyOFYyNmEyLDIsMCwwLDAsMi0yVjhIMjh2OUgyMS44M2wyLjU4LTIuNTlMMjMsMTNsLTUsNSw1LDUsMS40MS0xLjQxTDIxLjgzLDE5SDI4djlaIi8+JiN4YTsmI3hhOzxyZWN0IGhlaWdodD0iMzIiIHdpZHRoPSIzMiIgY2xhc3M9ImNscy0xIiBkYXRhLW5hbWU9IiZsdDtUcmFuc3BhcmVudCBSZWN0YW5nbGUmZ3Q7IiBpZD0iX1RyYW5zcGFyZW50X1JlY3RhbmdsZV8iLz4mI3hhOyYjeGE7PC9nPiYjeGE7JiN4YTs8L3N2Zz4=","w":64,"h":64}]
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | io.github.oneteme.assertapi
5 | assertapi-core
6 | 0.0.1
7 | jar
8 | assertapi-core
9 | assertapi-core
10 | https://oneteme.github.io/
11 |
12 |
13 | u$f
14 | usf.alami@gmail.com
15 | JARVIS
16 | https://oneteme.github.io/
17 |
18 |
19 |
20 | https://github.com/oneteme/assertapi-core
21 |
22 |
23 |
24 | Apache License 2.0
25 | https://github.com/oneteme/assertapi-core/blob/main/LICENSE
26 |
27 |
28 |
29 | 11
30 | 5.8.1
31 | 5.2.3.RELEASE
32 | 2.13.4
33 | UTF-8
34 | UTF-8
35 | ${java.version}
36 | ${java.version}
37 | jarvis
38 | https://sonarcloud.io
39 |
40 |
41 |
42 | org.projectlombok
43 | lombok
44 | 1.18.10
45 | provided
46 |
47 |
48 | org.springframework
49 | spring-web
50 | ${spring.version}
51 |
52 |
53 | org.skyscreamer
54 | jsonassert
55 | 1.5.0
56 |
57 |
58 | com.jayway.jsonpath
59 | json-path
60 | 2.7.0
61 |
62 |
63 | com.fasterxml.jackson.core
64 | jackson-core
65 | ${jackson.version}
66 |
67 |
68 | com.fasterxml.jackson.datatype
69 | jackson-datatype-jsr310
70 | ${jackson.version}
71 |
72 |
73 | com.fasterxml.jackson.module
74 | jackson-module-parameter-names
75 | ${jackson.version}
76 |
77 |
78 | org.junit.jupiter
79 | junit-jupiter-engine
80 | ${junit.version}
81 | test
82 |
83 |
84 | org.junit.jupiter
85 | junit-jupiter-params
86 | ${junit.version}
87 | test
88 |
89 |
90 | io.github.oneteme
91 | junit-addons
92 | 1.0.3
93 | test
94 |
95 |
96 |
97 |
98 |
99 | maven-compiler-plugin
100 | 3.6.2
101 |
102 | true
103 |
104 |
105 |
106 | org.apache.maven.plugins
107 | maven-surefire-plugin
108 | 3.0.0-M3
109 |
110 |
111 | org.jacoco
112 | jacoco-maven-plugin
113 | 0.8.7
114 |
115 |
116 | prepare-agent
117 |
118 | prepare-agent
119 |
120 |
121 |
122 | report
123 |
124 | report
125 |
126 |
127 |
128 | XML
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 | deploy
139 |
140 |
141 |
142 | org.apache.maven.plugins
143 | maven-source-plugin
144 | 2.2.1
145 |
146 |
147 | attach-sources
148 |
149 | jar-no-fork
150 |
151 |
152 |
153 |
154 |
155 | org.apache.maven.plugins
156 | maven-javadoc-plugin
157 | 2.9.1
158 |
159 |
160 | attach-javadocs
161 |
162 | jar
163 |
164 |
165 |
166 |
167 |
168 | org.apache.maven.plugins
169 | maven-gpg-plugin
170 | 1.5
171 |
172 |
173 | --pinentry-mode
174 | loopback
175 |
176 |
177 |
178 |
179 | sign-artifacts
180 | verify
181 |
182 | sign
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 | ossrh
194 | ossrh
195 | https://s01.oss.sonatype.org/content/repositories/snapshots/
196 |
197 |
198 |
199 |
200 | ossrh
201 | https://s01.oss.sonatype.org/content/repositories/snapshots/
202 |
203 |
204 | ossrh
205 | Central Repository OSSRH
206 | https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
207 |
208 |
209 |
210 |
--------------------------------------------------------------------------------
/src/main/java/org/usf/assertapi/core/AbstractModelTransformer.java:
--------------------------------------------------------------------------------
1 | package org.usf.assertapi.core;
2 |
3 | import static java.util.stream.Collectors.joining;
4 | import static org.usf.assertapi.core.PolymorphicType.jsonTypeName;
5 | import static org.usf.assertapi.core.ReleaseTarget.STABLE;
6 |
7 | import java.util.stream.Stream;
8 |
9 | import lombok.Getter;
10 |
11 | /**
12 | *
13 | * @author u$f
14 | * @since 1.0
15 | *
16 | */
17 | @Getter
18 | public abstract class AbstractModelTransformer implements ModelTransformer {
19 |
20 | private final ReleaseTarget[] applyOn;
21 |
22 | protected AbstractModelTransformer(ReleaseTarget[] applyOn) {
23 | this.applyOn = Utils.isEmpty(applyOn) ? new ReleaseTarget[] {STABLE} : applyOn;
24 | }
25 |
26 | public boolean matchTarget(ReleaseTarget target) {
27 | return Stream.of(applyOn).anyMatch(target::equals);
28 | }
29 |
30 | @Override
31 | public String toString() {
32 | return jsonTypeName(this.getClass()) + Stream.of(applyOn).map(Object::toString).collect(joining(",", "(", ")"));
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/usf/assertapi/core/ApiAssertionError.java:
--------------------------------------------------------------------------------
1 | package org.usf.assertapi.core;
2 |
3 | import lombok.Getter;
4 |
5 | /**
6 | *
7 | * @author u$f
8 | * @since 1.0
9 | *
10 | */
11 | @Getter
12 | @SuppressWarnings("serial")
13 | public final class ApiAssertionError extends AssertionError {
14 |
15 | private final transient boolean skipped;
16 | private final transient Object expected;
17 | private final transient Object actual;
18 |
19 | public ApiAssertionError(Object expected, Object actual, String msg) {
20 | this(false, expected, actual, msg);
21 | }
22 |
23 | private ApiAssertionError(boolean skipped, Object expected, Object actual, String msg) {
24 | super(msg);
25 | this.skipped = skipped;
26 | this.expected = expected;
27 | this.actual = actual;
28 | }
29 |
30 | public static ApiAssertionError skippedAssertionError(String msg) {
31 | return new ApiAssertionError(true, null, null, msg);
32 | }
33 |
34 | public static boolean wasSkipped(Throwable t) {
35 | return t instanceof ApiAssertionError && ((ApiAssertionError)t).isSkipped();
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/usf/assertapi/core/ApiAssertionFactory.java:
--------------------------------------------------------------------------------
1 | package org.usf.assertapi.core;
2 |
3 | import static java.util.Collections.unmodifiableMap;
4 | import static java.util.Objects.requireNonNullElseGet;
5 | import static org.usf.assertapi.core.RestTemplateBuilder.defaultAuthenticators;
6 |
7 | import java.util.HashMap;
8 | import java.util.Map;
9 | import java.util.function.BiConsumer;
10 |
11 | import lombok.NonNull;
12 |
13 | /**
14 | *
15 | * @author u$f
16 | * @since 1.0
17 | *
18 | */
19 | public final class ApiAssertionFactory {
20 |
21 | //init with default authenticators
22 | private final Map> clientAuthenticators = new HashMap<>(defaultAuthenticators);
23 | private ResponseComparator comparator;
24 | private ServerConfig stableRelease;
25 | private ServerConfig latestRelease;
26 | private BiConsumer tracer;
27 |
28 | public ApiAssertionFactory register(@NonNull String name, @NonNull Class extends ClientAuthenticator> c) {
29 | clientAuthenticators.put(name, c);
30 | return this;
31 | }
32 |
33 | public ApiAssertionFactory comparingStatically(@NonNull ServerConfig latestRelease) {
34 | return comparing(null, latestRelease);
35 | }
36 |
37 | public ApiAssertionFactory comparing(ServerConfig stableRelease, @NonNull ServerConfig latestRelease) {
38 | this.stableRelease = stableRelease;
39 | this.latestRelease = latestRelease;
40 | return this;
41 | }
42 |
43 | public ApiAssertionFactory using(@NonNull ResponseComparator comparator) {
44 | this.comparator = comparator;
45 | return this;
46 | }
47 |
48 | public ApiAssertionFactory trace(@NonNull BiConsumer tracer) {
49 | this.tracer = tracer;
50 | return this;
51 | }
52 |
53 | public ResponseComparator build() {
54 | var map = unmodifiableMap(clientAuthenticators);
55 | var latestTemp = RestTemplateBuilder.build(latestRelease, map);
56 | var cmp = requireNonNullElseGet(comparator, ResponseComparator::new);
57 | cmp.setExecutor(stableRelease == null
58 | ? new DisconnectedAssertionExecutor(latestTemp)
59 | : new ConnectedAssertionExecutor(RestTemplateBuilder.build(stableRelease, map), latestTemp));
60 | if(tracer != null) {
61 | cmp = new ResponseComparatorProxy(cmp, tracer);
62 | }
63 | return cmp;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/org/usf/assertapi/core/ApiAssertionRuntimeException.java:
--------------------------------------------------------------------------------
1 | package org.usf.assertapi.core;
2 |
3 | /**
4 | *
5 | * @author u$f
6 | * @since 1.0
7 | *
8 | */
9 | @SuppressWarnings("serial")
10 | public class ApiAssertionRuntimeException extends RuntimeException {
11 |
12 | public ApiAssertionRuntimeException(String message) {
13 | super(message);
14 | }
15 |
16 | public ApiAssertionRuntimeException(String message, Throwable cause) {
17 | super(message, cause);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/usf/assertapi/core/ApiExecutor.java:
--------------------------------------------------------------------------------
1 | package org.usf.assertapi.core;
2 |
3 | import lombok.Getter;
4 | import lombok.RequiredArgsConstructor;
5 |
6 | @FunctionalInterface
7 | public interface ApiExecutor {
8 |
9 | PairResponse exchange(ApiRequest api);
10 |
11 | @Getter
12 | @RequiredArgsConstructor
13 | final class PairResponse {
14 |
15 | private final ClientResponseWrapper expected;
16 | private final ClientResponseWrapper actual;
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/src/main/java/org/usf/assertapi/core/ApiRequest.java:
--------------------------------------------------------------------------------
1 | package org.usf.assertapi.core;
2 |
3 | import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
4 | import static java.util.Collections.emptyMap;
5 | import static java.util.Objects.requireNonNullElse;
6 | import static java.util.Objects.requireNonNullElseGet;
7 | import static org.usf.assertapi.core.ExecutionConfig.DEFAULT_CONFIG;
8 | import static org.usf.assertapi.core.Utils.isEmpty;
9 |
10 | import java.net.URI;
11 | import java.util.Collections;
12 | import java.util.Map;
13 | import java.util.stream.IntStream;
14 |
15 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
16 | import com.fasterxml.jackson.annotation.JsonInclude;
17 |
18 | import lombok.Getter;
19 | import lombok.Setter;
20 |
21 | /**
22 | *
23 | * @author u$f
24 | * @since 1.0
25 | *
26 | */
27 | @Getter
28 | @Setter
29 | @JsonInclude(NON_NULL)
30 | @JsonIgnoreProperties("location")
31 | public final class ApiRequest extends HttpRequest {
32 |
33 | private static final String DEFAULT_COMPARTOR_KEY = "*";
34 |
35 | private Long id;
36 | private String name;
37 | private Integer version;
38 | private String description; //case description
39 | private int[] accept = {DEFAULT_STATUS};
40 | private Map> comparators = emptyMap(); //nullable
41 | //TD private Map> headersCompartors;
42 | private ExecutionConfig execution = DEFAULT_CONFIG;
43 | private HttpRequest stable;
44 | private StaticResponse response;
45 |
46 | private String lazyComparators;
47 |
48 | public void setExecution(ExecutionConfig config) {
49 | this.execution = requireNonNullElse(config, DEFAULT_CONFIG);
50 | }
51 |
52 | public void setAccept(int[] accept) {
53 | this.accept = isEmpty(accept) ? new int[] {DEFAULT_STATUS} : accept; //OK or may be NotFound ?
54 | }
55 |
56 | public void setComparator(ModelComparator> comparator) {
57 | this.comparators = Map.of(DEFAULT_COMPARTOR_KEY, comparator);
58 | }
59 |
60 | public void setComparators(Map> comparators) {
61 | this.comparators = requireNonNullElseGet(comparators, Collections::emptyMap);
62 | }
63 |
64 | public ModelComparator> comparator(int status) {
65 | var key = ""+status;
66 | return comparators.containsKey(key)
67 | ? comparators.get(key)
68 | : comparators.get(DEFAULT_COMPARTOR_KEY); // optional comparator ==> nullable
69 | }
70 |
71 | public HttpRequest latest() {
72 | return this;
73 | }
74 |
75 | public HttpRequest stable() {
76 | return requireNonNullElse(stable, this); // RUN : TNR == MIGRATION
77 | }
78 |
79 | public StaticResponse response() {
80 | return response;
81 | }
82 |
83 | public boolean accept(int status) {
84 | return IntStream.of(accept).anyMatch(v-> v == status);
85 | }
86 |
87 | public ApiRequest withLocation(URI location) {
88 | if(response != null) {
89 | response.setLocation(location);
90 | }
91 | if(stable != null) {
92 | stable.setLocation(location);
93 | }
94 | setLocation(location);
95 | return this;
96 | }
97 |
98 | @Override
99 | public String toString() {
100 | var sb = new StringBuilder();
101 | if(name != null) {
102 | sb.append("[").append(name).append("] ");
103 | }
104 | if(description != null) {
105 | sb.append(description);
106 | }
107 | return sb.length() == 0 ? super.toString() : sb.toString(); //isEmpty java15
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/src/main/java/org/usf/assertapi/core/BasicClientAuthenticator.java:
--------------------------------------------------------------------------------
1 | package org.usf.assertapi.core;
2 |
3 | import static org.usf.assertapi.core.ClientAuthenticator.ServerAuthMethod.BASIC;
4 | import static org.usf.assertapi.core.Utils.requireNonEmpty;
5 |
6 | import org.springframework.http.HttpHeaders;
7 |
8 | /**
9 | *
10 | * @author u$f
11 | * @since 1.0
12 | *
13 | */
14 | public final class BasicClientAuthenticator implements ClientAuthenticator {
15 |
16 | @Override
17 | public void authorization(HttpHeaders headers, ServerAuth auth) {
18 | headers.setBasicAuth(
19 | requireNonEmpty(auth.getUsername(), BASIC.name(), "username"),
20 | requireNonEmpty(auth.getPassword(), BASIC.name(), "password"));
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/usf/assertapi/core/BearerClientAuthenticator.java:
--------------------------------------------------------------------------------
1 | package org.usf.assertapi.core;
2 |
3 | import static java.util.Objects.requireNonNull;
4 | import static java.util.Objects.requireNonNullElseGet;
5 | import static java.util.Optional.ofNullable;
6 | import static org.springframework.http.HttpMethod.POST;
7 | import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED;
8 |
9 | import java.util.Map;
10 |
11 | import org.springframework.core.ParameterizedTypeReference;
12 | import org.springframework.http.HttpEntity;
13 | import org.springframework.http.HttpHeaders;
14 | import org.springframework.http.ResponseEntity;
15 | import org.springframework.util.LinkedMultiValueMap;
16 | import org.springframework.util.MultiValueMap;
17 | import org.springframework.web.client.RestTemplate;
18 |
19 | /**
20 | *
21 | * @author u$f
22 | * @since 1.0
23 | *
24 | */
25 | public final class BearerClientAuthenticator implements ClientAuthenticator {
26 |
27 | @Override
28 | public void authorization(HttpHeaders headers, ServerAuth auth) {
29 | headers.setBearerAuth(requireNonNullElseGet(auth.getToken(), ()-> fetchIdToken(auth)));
30 | }
31 |
32 | @Deprecated(forRemoval = true) //specific nova
33 | private static String fetchIdToken(ServerAuth auth) {
34 | var headers = new HttpHeaders();
35 | headers.setContentType(APPLICATION_FORM_URLENCODED);
36 | headers.setBasicAuth(requireNonNull(auth.getUsername()), requireNonNull(auth.getPassword()));
37 | MultiValueMap map = new LinkedMultiValueMap<>();
38 | map.add("grant_type", "client_credentials");
39 | map.add("scope", "openid");
40 | HttpEntity> request = new HttpEntity<>(map, headers);
41 | ResponseEntity