Skip to content
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

[MD] Fix update data source & block update endpoint #2364

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,19 @@ export class DataSourceSavedObjectsClientWrapper {
}

private async validateAndUpdatePartialAttributes<T = unknown>(attributes: T) {
const { auth } = attributes;
const { auth, endpoint } = attributes;

if (endpoint) {
throw SavedObjectsErrorHelpers.createBadRequestError(
`Update data source endpoint is not supported`
);
}

if (auth === undefined) {
return attributes;
}

const {
type,
credentials: { password },
} = auth;
const { type, credentials } = auth;

switch (type) {
case AuthType.NoAuth:
Expand All @@ -179,7 +182,7 @@ export class DataSourceSavedObjectsClientWrapper {
credentials: undefined,
};
case AuthType.UsernamePasswordType:
if (password) {
if (credentials && credentials.password) {
return {
...attributes,
auth: await this.encryptCredentials(auth),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ export class EditDataSourceForm extends React.Component<EditDataSourceProps, Edi

onClickUpdateDataSource = () => {
if (this.isFormValid()) {
// update data source endpoint is currently not supported/allowed
const formValues: DataSourceAttributes = {
title: this.state.title,
description: this.state.description,
endpoint: this.props.existingDataSource.endpoint,
auth: this.state.auth,
};
/* Remove credentials object for NoAuth */
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data_source_management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const credentialSourceOptions = [
export interface DataSourceAttributes extends SavedObjectAttributes {
title: string;
description?: string;
endpoint: string;
endpoint?: string;
auth: {
type: AuthType;
credentials: UsernamePasswordTypedContent | undefined;
Expand Down