mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
Don't send cred user with org
This commit is contained in:
parent
a669db989c
commit
35e5c7f309
@ -495,7 +495,10 @@ function AddEditCredentialsController (
|
||||
}
|
||||
|
||||
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)) {
|
||||
delete data.inputs[gceFileInputSchema.id];
|
||||
@ -524,7 +527,11 @@ function AddEditCredentialsController (
|
||||
* Otherwise inputs are merged together making the request invalid.
|
||||
*/
|
||||
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');
|
||||
|
||||
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 {
|
||||
data: { id: newCredentialId },
|
||||
} = await CredentialsAPI.create({
|
||||
user: (me && me.id) || null,
|
||||
organization: (organization && organization.id) || null,
|
||||
inputs: nonPluginInputs,
|
||||
...remainingValues,
|
||||
});
|
||||
} = await CredentialsAPI.create(modifiedData);
|
||||
|
||||
await Promise.all(
|
||||
Object.entries(pluginInputs).map(([key, value]) =>
|
||||
|
||||
@ -127,7 +127,6 @@ describe('<CredentialAdd />', () => {
|
||||
await act(async () => {
|
||||
wrapper.find('CredentialForm').prop('onSubmit')({
|
||||
user: 1,
|
||||
organization: null,
|
||||
name: 'foo',
|
||||
description: 'bar',
|
||||
credential_type: '1',
|
||||
@ -156,7 +155,6 @@ describe('<CredentialAdd />', () => {
|
||||
});
|
||||
expect(CredentialsAPI.create).toHaveBeenCalledWith({
|
||||
user: 1,
|
||||
organization: null,
|
||||
name: 'foo',
|
||||
description: 'bar',
|
||||
credential_type: '1',
|
||||
|
||||
@ -80,13 +80,15 @@ function CredentialEdit({ credential, me }) {
|
||||
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([
|
||||
CredentialsAPI.update(credential.id, {
|
||||
user: (me && me.id) || null,
|
||||
organization: (organization && organization.id) || null,
|
||||
inputs: nonPluginInputs,
|
||||
...remainingValues,
|
||||
}),
|
||||
CredentialsAPI.update(credential.id, modifiedData),
|
||||
...destroyInputSources(),
|
||||
]);
|
||||
|
||||
|
||||
@ -277,7 +277,6 @@ describe('<CredentialEdit />', () => {
|
||||
await act(async () => {
|
||||
wrapper.find('CredentialForm').prop('onSubmit')({
|
||||
user: 1,
|
||||
organization: null,
|
||||
name: 'foo',
|
||||
description: 'bar',
|
||||
credential_type: '1',
|
||||
@ -316,7 +315,6 @@ describe('<CredentialEdit />', () => {
|
||||
});
|
||||
expect(CredentialsAPI.update).toHaveBeenCalledWith(3, {
|
||||
user: 1,
|
||||
organization: null,
|
||||
name: 'foo',
|
||||
description: 'bar',
|
||||
credential_type: '1',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user