-
Notifications
You must be signed in to change notification settings - Fork 1.4k
UI: submit object storage creation using POST #13768
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
Open
Dogface2k
wants to merge
4
commits into
apache:4.22
Choose a base branch
from
Dogface2k:fix/object-storage-post
base: 4.22
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fdb1c14
UI: submit object storage creation using POST
Dogface2k d4712cd
UI: prevent credential exposure in object storage errors
Dogface2k fe572b3
API: centralize credential-safe request diagnostics
Dogface2k 4bac5d4
UI: avoid logging API errors in browser console
Dogface2k 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
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
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
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
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,99 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| import mockAxios from '../../../mock/mockAxios' | ||
| import AddObjectStorage from '@/views/infra/AddObjectStorage' | ||
| import { mount } from '@vue/test-utils' | ||
|
|
||
| jest.mock('axios', () => mockAxios) | ||
| jest.mock('@/vue-app', () => ({ | ||
| vueProps: { | ||
| $localStorage: { | ||
| get: jest.fn(() => null) | ||
| } | ||
| } | ||
| })) | ||
|
|
||
| describe('Views > infra > AddObjectStorage.vue', () => { | ||
| beforeEach(() => { | ||
| mockAxios.mockReset() | ||
| }) | ||
|
|
||
| it('submits addObjectStoragePool using POST with the request in the body', async () => { | ||
| mockAxios.mockResolvedValue({}) | ||
|
|
||
| const params = { | ||
| name: 'test-store', | ||
| provider: 'MinIO', | ||
| url: 'https://object-storage.example.test', | ||
| 'details[0].key': 'accesskey', | ||
| 'details[0].value': 'test-access-key', | ||
| 'details[1].key': 'secretkey', | ||
| 'details[1].value': 'test-secret+key&with=symbols' | ||
| } | ||
|
|
||
| await AddObjectStorage.methods.addObjectStore(params) | ||
|
|
||
| expect(mockAxios).toHaveBeenCalledTimes(1) | ||
| const request = mockAxios.mock.calls[0][0] | ||
| expect(request).toMatchObject({ | ||
| url: '/', | ||
| method: 'POST' | ||
| }) | ||
| expect(request.params).toBeUndefined() | ||
| expect(request.data).toBeInstanceOf(URLSearchParams) | ||
| expect(request.data.get('command')).toBe('addObjectStoragePool') | ||
| expect(request.data.get('response')).toBe('json') | ||
| expect(request.data.get('url')).toBe(params.url) | ||
| expect(request.data.get('details[0].value')).toBe(params['details[0].value']) | ||
| expect(request.data.get('details[1].value')).toBe(params['details[1].value']) | ||
| }) | ||
|
|
||
| it('propagates an addObjectStoragePool API failure', async () => { | ||
| const error = new Error('request failed') | ||
| mockAxios.mockRejectedValue(error) | ||
|
|
||
| await expect(AddObjectStorage.methods.addObjectStore({})).rejects.toBe(error) | ||
| }) | ||
|
|
||
| it('masks the object storage secret key', () => { | ||
| const wrapper = mount(AddObjectStorage, { | ||
| props: { | ||
| resource: {} | ||
| }, | ||
| global: { | ||
| mocks: { | ||
| $getApiParams: jest.fn(() => ({ | ||
| name: {}, | ||
| provider: {}, | ||
| url: {}, | ||
| size: {} | ||
| })), | ||
| $t: key => key | ||
| }, | ||
| provide: { | ||
| parentFetchData: jest.fn() | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| const secretKeyInput = wrapper.find('input[type="password"]') | ||
|
|
||
| expect(secretKeyInput.exists()).toBe(true) | ||
| expect(secretKeyInput.attributes('autocomplete')).toBe('off') | ||
| }) | ||
| }) |
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.