Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: SonarSource/sonar-scanner-npm
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a7143c2b36724ab3e20c32ccf86eb6ca975801d4
Choose a base ref
...
head repository: SonarSource/sonar-scanner-npm
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 182af86acd05d63880605a8f11f174896ed59acd
Choose a head ref
  • 1 commit
  • 4 files changed
  • 1 contributor

Commits on Aug 14, 2024

  1. SCANNPM-42 Allow scan to run without a token provided (#161)

    lucas-paulger-sonarsource authored Aug 14, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    182af86 View commit details
Showing with 22 additions and 6 deletions.
  1. +2 −2 package-lock.json
  2. +1 −1 package.json
  3. +1 −3 src/request.ts
  4. +18 −0 test/unit/request.test.ts
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sonarqube-scanner",
"description": "SonarQube/SonarCloud Scanner for the JavaScript world",
"version": "4.2.0",
"version": "4.2.1",
"homepage": "https://github.com/SonarSource/sonar-scanner-npm",
"author": {
"name": "Fabrice Bellingard",
4 changes: 1 addition & 3 deletions src/request.ts
Original file line number Diff line number Diff line change
@@ -116,9 +116,7 @@ export async function initializeAxios(properties: ScannerProperties) {
_axiosInstances = {
internal: axios.create({
baseURL,
headers: {
Authorization: `Bearer ${token}`,
},
headers: token ? { Authorization: `Bearer ${token}` } : {},
timeout,
...agents,
}),
18 changes: 18 additions & 0 deletions test/unit/request.test.ts
Original file line number Diff line number Diff line change
@@ -208,6 +208,24 @@ describe('request', () => {
timeout: 23000,
});
});

it('should initialize axios without token', async () => {
jest.spyOn(axios, 'create');

await initializeAxios({
[ScannerProperty.SonarHostUrl]: SONARCLOUD_URL,
[ScannerProperty.SonarScannerApiBaseUrl]: SONARCLOUD_API_BASE_URL,
});

expect(axios.create).toHaveBeenCalledWith({
baseURL: SONARCLOUD_API_BASE_URL,
headers: {},
timeout: 0,
});
expect(axios.create).toHaveBeenCalledWith({
timeout: 0,
});
});
});

describe('fetch', () => {