-
Notifications
You must be signed in to change notification settings - Fork 104
chore(calm-hub-ui): migrate from fetch to axios #2137
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
Merged
markscott-ms
merged 14 commits into
finos:main
from
selwyntheo:chore/issue-979-migrate-fetch-to-axios
Mar 30, 2026
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
71323fd
chore(calm-hub-ui): migrate from fetch to axios (#979)
selwyntheo c4acffa
Merge remote-tracking branch 'origin/main' into chore/issue-979-migra…
rocketstack-matt 486c338
Merge branch 'main' into chore/issue-979-migrate-fetch-to-axios
rocketstack-matt 7df0d29
Merge branch 'main' into chore/issue-979-migrate-fetch-to-axios
rocketstack-matt f6fab76
Merge branch 'main' into chore/issue-979-migrate-fetch-to-axios
rocketstack-matt 330cb5d
fix(calm-hub-ui): address PR review comments
selwyntheo f8126c2
fix(calm-hub-ui): address final PR review comments
selwyntheo 6dbf904
chore(calm-hub-ui): resolve merge conflicts with main
selwyntheo 31c9fb4
fix(calm-hub-ui): protect against reintroduction of format string inj…
markscott-ms fe0f7f6
Merge branch 'main' into chore/issue-979-migrate-fetch-to-axios
markscott-ms d1cd2c2
fix(calm-hub-ui): fetching of namespaces now they are objects
markscott-ms 6b80a04
fix(calm-hub-ui): remove unused imports
markscott-ms a431372
fix(calm-hub-ui): update test for namespaces fetch now they are objects
markscott-ms a7fbbd5
Merge branch 'main' into chore/issue-979-migrate-fetch-to-axios
markscott-ms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import { afterEach, describe, expect, it, vi } from 'vitest'; | ||
| import axios from 'axios'; | ||
| import { | ||
| checkAuthorityService, | ||
| getToken, | ||
| getAuthHeaders, | ||
| isAuthServiceEnabled, | ||
| } from './authService.js'; | ||
|
|
||
| vi.mock('axios'); | ||
|
|
||
| describe('authService', () => { | ||
| afterEach(() => { | ||
| vi.restoreAllMocks(); | ||
| }); | ||
|
|
||
| describe('checkAuthorityService', () => { | ||
| it('should return true when the authority service responds successfully', async () => { | ||
| vi.mocked(axios.head).mockResolvedValue({ status: 200 }); | ||
| const result = await checkAuthorityService(); | ||
| expect(result).toBe(true); | ||
| }); | ||
|
|
||
| it('should return false when the authority service request fails', async () => { | ||
| vi.mocked(axios.head).mockRejectedValue(new Error('Network Error')); | ||
| const result = await checkAuthorityService(); | ||
| expect(result).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe('isAuthServiceEnabled', () => { | ||
| it('should return false when AUTH_SERVICE_OIDC_ENABLE is false', () => { | ||
| const result = isAuthServiceEnabled(); | ||
| expect(result).toBe(false); | ||
| }); | ||
|
|
||
| it('should return false when protocol is http even if OIDC is enabled', () => { | ||
| const originalProtocol = window.location.protocol; | ||
| Object.defineProperty(window, 'location', { | ||
| value: { ...window.location, protocol: 'http:' }, | ||
| writable: true, | ||
| }); | ||
|
|
||
| const result = isAuthServiceEnabled(); | ||
| expect(result).toBe(false); | ||
|
|
||
| Object.defineProperty(window, 'location', { | ||
| value: { ...window.location, protocol: originalProtocol }, | ||
| writable: true, | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getToken', () => { | ||
| it('should return empty string when AUTH_SERVICE_OIDC_ENABLE is false', async () => { | ||
| const token = await getToken(); | ||
| expect(token).toBe(''); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getAuthHeaders', () => { | ||
| it('should return empty headers object when no token is available', async () => { | ||
| const headers = await getAuthHeaders(); | ||
| expect(headers).toEqual({}); | ||
| }); | ||
|
|
||
| it('should return headers with Authorization when token is available', async () => { | ||
| vi.doMock('./authService.js', async (importOriginal) => { | ||
| const actual = await importOriginal<typeof import('./authService.js')>(); | ||
| return { | ||
| ...actual, | ||
| getToken: vi.fn().mockResolvedValue('test-token'), | ||
| }; | ||
| }); | ||
|
|
||
| const headers = await getAuthHeaders(); | ||
| expect(headers).toEqual({}); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.