mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 15:36:04 -03:30
Don't send cred user with org
This commit is contained in:
@@ -495,7 +495,10 @@ function AddEditCredentialsController (
|
|||||||
}
|
}
|
||||||
|
|
||||||
function create (data) {
|
function create (data) {
|
||||||
data.user = me.get('id');
|
// can send only one of org, user, team
|
||||||
|
if (!data.organization && !data.team) {
|
||||||
|
data.user = me.get('id');
|
||||||
|
}
|
||||||
|
|
||||||
if (_.get(data.inputs, gceFileInputSchema.id)) {
|
if (_.get(data.inputs, gceFileInputSchema.id)) {
|
||||||
delete data.inputs[gceFileInputSchema.id];
|
delete data.inputs[gceFileInputSchema.id];
|
||||||
@@ -524,7 +527,11 @@ function AddEditCredentialsController (
|
|||||||
* Otherwise inputs are merged together making the request invalid.
|
* Otherwise inputs are merged together making the request invalid.
|
||||||
*/
|
*/
|
||||||
function update (data) {
|
function update (data) {
|
||||||
data.user = me.get('id');
|
// can send only one of org, user, team
|
||||||
|
if (!data.organization && !data.team) {
|
||||||
|
data.user = me.get('id');
|
||||||
|
}
|
||||||
|
|
||||||
credential.unset('inputs');
|
credential.unset('inputs');
|
||||||
|
|
||||||
if (_.get(data.inputs, gceFileInputSchema.id)) {
|
if (_.get(data.inputs, gceFileInputSchema.id)) {
|
||||||
|
|||||||
@@ -52,14 +52,16 @@ function CredentialAdd({ me }) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const modifiedData = { inputs: nonPluginInputs, ...remainingValues };
|
||||||
|
// can send only one of org, user, team
|
||||||
|
if (organization?.id) {
|
||||||
|
modifiedData.organization = organization.id;
|
||||||
|
} else if (me?.id) {
|
||||||
|
modifiedData.user = me.id;
|
||||||
|
}
|
||||||
const {
|
const {
|
||||||
data: { id: newCredentialId },
|
data: { id: newCredentialId },
|
||||||
} = await CredentialsAPI.create({
|
} = await CredentialsAPI.create(modifiedData);
|
||||||
user: (me && me.id) || null,
|
|
||||||
organization: (organization && organization.id) || null,
|
|
||||||
inputs: nonPluginInputs,
|
|
||||||
...remainingValues,
|
|
||||||
});
|
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
Object.entries(pluginInputs).map(([key, value]) =>
|
Object.entries(pluginInputs).map(([key, value]) =>
|
||||||
|
|||||||
@@ -127,7 +127,6 @@ describe('<CredentialAdd />', () => {
|
|||||||
await act(async () => {
|
await act(async () => {
|
||||||
wrapper.find('CredentialForm').prop('onSubmit')({
|
wrapper.find('CredentialForm').prop('onSubmit')({
|
||||||
user: 1,
|
user: 1,
|
||||||
organization: null,
|
|
||||||
name: 'foo',
|
name: 'foo',
|
||||||
description: 'bar',
|
description: 'bar',
|
||||||
credential_type: '1',
|
credential_type: '1',
|
||||||
@@ -156,7 +155,6 @@ describe('<CredentialAdd />', () => {
|
|||||||
});
|
});
|
||||||
expect(CredentialsAPI.create).toHaveBeenCalledWith({
|
expect(CredentialsAPI.create).toHaveBeenCalledWith({
|
||||||
user: 1,
|
user: 1,
|
||||||
organization: null,
|
|
||||||
name: 'foo',
|
name: 'foo',
|
||||||
description: 'bar',
|
description: 'bar',
|
||||||
credential_type: '1',
|
credential_type: '1',
|
||||||
|
|||||||
@@ -80,13 +80,15 @@ function CredentialEdit({ credential, me }) {
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const modifiedData = { inputs: nonPluginInputs, ...remainingValues };
|
||||||
|
// can send only one of org, user, team
|
||||||
|
if (organization?.id) {
|
||||||
|
modifiedData.organization = organization.id;
|
||||||
|
} else if (me?.id) {
|
||||||
|
modifiedData.user = me.id;
|
||||||
|
}
|
||||||
const [{ data }] = await Promise.all([
|
const [{ data }] = await Promise.all([
|
||||||
CredentialsAPI.update(credential.id, {
|
CredentialsAPI.update(credential.id, modifiedData),
|
||||||
user: (me && me.id) || null,
|
|
||||||
organization: (organization && organization.id) || null,
|
|
||||||
inputs: nonPluginInputs,
|
|
||||||
...remainingValues,
|
|
||||||
}),
|
|
||||||
...destroyInputSources(),
|
...destroyInputSources(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -277,7 +277,6 @@ describe('<CredentialEdit />', () => {
|
|||||||
await act(async () => {
|
await act(async () => {
|
||||||
wrapper.find('CredentialForm').prop('onSubmit')({
|
wrapper.find('CredentialForm').prop('onSubmit')({
|
||||||
user: 1,
|
user: 1,
|
||||||
organization: null,
|
|
||||||
name: 'foo',
|
name: 'foo',
|
||||||
description: 'bar',
|
description: 'bar',
|
||||||
credential_type: '1',
|
credential_type: '1',
|
||||||
@@ -316,7 +315,6 @@ describe('<CredentialEdit />', () => {
|
|||||||
});
|
});
|
||||||
expect(CredentialsAPI.update).toHaveBeenCalledWith(3, {
|
expect(CredentialsAPI.update).toHaveBeenCalledWith(3, {
|
||||||
user: 1,
|
user: 1,
|
||||||
organization: null,
|
|
||||||
name: 'foo',
|
name: 'foo',
|
||||||
description: 'bar',
|
description: 'bar',
|
||||||
credential_type: '1',
|
credential_type: '1',
|
||||||
|
|||||||
Reference in New Issue
Block a user