mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
Fixed multi credential service unit test failures
Signed-off-by: mabashian <mabashia@redhat.com>
This commit is contained in:
@@ -138,7 +138,7 @@ export default ['Rest', 'ProcessErrors', '$q', 'GetBasePath', function(Rest, Pro
|
|||||||
name: cred.name,
|
name: cred.name,
|
||||||
id: cred.id,
|
id: cred.id,
|
||||||
postType: cred.postType,
|
postType: cred.postType,
|
||||||
readOnly: cred.readOnly,
|
readOnly: cred.readOnly ? true : false,
|
||||||
kind: typeOpts
|
kind: typeOpts
|
||||||
.filter(type => {
|
.filter(type => {
|
||||||
return parseInt(cred.credential_type) === type.value;
|
return parseInt(cred.credential_type) === type.value;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
'use strict'
|
'use strict';
|
||||||
|
|
||||||
describe('MultiCredentialService', () => {
|
describe('MultiCredentialService', () => {
|
||||||
let MultiCredentialService;
|
let MultiCredentialService;
|
||||||
@@ -79,7 +79,7 @@ describe('MultiCredentialService', () => {
|
|||||||
expect(equal).toBe(true);
|
expect(equal).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return array of selected credentials (populated)', () => {
|
it('should return array of selected credentials (populated, not read only)', () => {
|
||||||
let creds = {
|
let creds = {
|
||||||
machine: {
|
machine: {
|
||||||
credential_type: 1,
|
credential_type: 1,
|
||||||
@@ -120,18 +120,92 @@ describe('MultiCredentialService', () => {
|
|||||||
name: 'ssh',
|
name: 'ssh',
|
||||||
id: 3,
|
id: 3,
|
||||||
postType: 'machine',
|
postType: 'machine',
|
||||||
|
readOnly: false,
|
||||||
kind: 'SSH:'
|
kind: 'SSH:'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'aws',
|
name: 'aws',
|
||||||
id: 4,
|
id: 4,
|
||||||
postType: 'extra',
|
postType: 'extra',
|
||||||
|
readOnly: false,
|
||||||
kind: 'Amazon Web Services:'
|
kind: 'Amazon Web Services:'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'gce',
|
name: 'gce',
|
||||||
id: 5,
|
id: 5,
|
||||||
postType: 'extra',
|
postType: 'extra',
|
||||||
|
readOnly: false,
|
||||||
|
kind: 'Google Compute Engine:'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
let actual = MultiCredentialService
|
||||||
|
.updateCredentialTags(creds, typeOpts);
|
||||||
|
|
||||||
|
let equal = _.isEqual(expected.sort(), actual.sort());
|
||||||
|
|
||||||
|
expect(equal).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return array of selected credentials (populated, read only)', () => {
|
||||||
|
let creds = {
|
||||||
|
machine: {
|
||||||
|
credential_type: 1,
|
||||||
|
id: 3,
|
||||||
|
name: 'ssh',
|
||||||
|
readOnly: true
|
||||||
|
},
|
||||||
|
extra: [
|
||||||
|
{
|
||||||
|
credential_type: 2,
|
||||||
|
id: 4,
|
||||||
|
name: 'aws',
|
||||||
|
readOnly: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
credential_type: 3,
|
||||||
|
id: 5,
|
||||||
|
name: 'gce',
|
||||||
|
readOnly: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
let typeOpts = [
|
||||||
|
{
|
||||||
|
name: 'SSH',
|
||||||
|
value: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Amazon Web Services',
|
||||||
|
value: 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Google Compute Engine',
|
||||||
|
value: 3
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
let expected = [
|
||||||
|
{
|
||||||
|
name: 'ssh',
|
||||||
|
id: 3,
|
||||||
|
postType: 'machine',
|
||||||
|
readOnly: true,
|
||||||
|
kind: 'SSH:'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'aws',
|
||||||
|
id: 4,
|
||||||
|
postType: 'extra',
|
||||||
|
readOnly: true,
|
||||||
|
kind: 'Amazon Web Services:'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'gce',
|
||||||
|
id: 5,
|
||||||
|
postType: 'extra',
|
||||||
|
readOnly: true,
|
||||||
kind: 'Google Compute Engine:'
|
kind: 'Google Compute Engine:'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user