test: 💍 acceptance tests for rdp target brokered creds
This commit is contained in:
1 parent
9edc90306e
commit
33cb7e0a50
2 files changed
+869
-390
No files matched your search
File diff suppressed because it is too large.
Load diff
+81
@@ -9,6 +9,12 @@ import { currentURL, visit } from '@ember/test-helpers';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { setupSqlite } from 'api/test-support/helpers/sqlite';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
import {
|
||||
TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN,
|
||||
TYPE_CREDENTIAL_USERNAME_PASSWORD,
|
||||
} from 'api/models/credential';
|
||||
import { TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC } from 'api/models/credential-library';
|
||||
import { TYPE_TARGET_RDP } from 'api/models/target';
|
||||
|
||||
module(
|
||||
'Unit | Controller | scopes/scope/targets/target/add-brokered-credential-sources',
|
||||
@@ -114,5 +120,80 @@ module(
|
||||
|
||||
assert.strictEqual(currentURL(), urls.credentialSources);
|
||||
});
|
||||
|
||||
test('hasAvailableBrokeredCredentialSources returns true if target has available credentials for RDP target', function (assert) {
|
||||
const target = store.createRecord('target', {
|
||||
brokered_credential_source_ids: [{ value: 'cred_123' }],
|
||||
type: TYPE_TARGET_RDP,
|
||||
});
|
||||
const credentialLibraries = [
|
||||
store.createRecord('credential-library', {
|
||||
credential_type: TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN,
|
||||
}),
|
||||
];
|
||||
const credentials = [
|
||||
store.createRecord('credential', {
|
||||
type: TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN,
|
||||
}),
|
||||
];
|
||||
controller.set('model', { target, credentialLibraries, credentials });
|
||||
|
||||
assert.true(controller.hasAvailableBrokeredCredentialSources);
|
||||
});
|
||||
|
||||
test('hasAvailableBrokeredCredentialSources returns false if target has no available credentials for RDP target', function (assert) {
|
||||
const target = store.createRecord('target', {
|
||||
brokered_credential_source_ids: [{ value: 'cred_123' }],
|
||||
type: TYPE_TARGET_RDP,
|
||||
});
|
||||
controller.set('model', {
|
||||
target,
|
||||
credentialLibraries: [],
|
||||
credentials: [],
|
||||
});
|
||||
|
||||
assert.false(controller.hasAvailableBrokeredCredentialSources);
|
||||
});
|
||||
|
||||
test('filteredCredentialSources returns credential libraries and credentials not already added to RDP target', function (assert) {
|
||||
const credential1 = store.createRecord('credential', {
|
||||
id: 'cred_1',
|
||||
type: TYPE_CREDENTIAL_USERNAME_PASSWORD,
|
||||
});
|
||||
const credential2 = store.createRecord('credential', {
|
||||
id: 'cred_2',
|
||||
type: TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN,
|
||||
});
|
||||
|
||||
const credentialLibrary1 = store.createRecord('credential-library', {
|
||||
id: 'lib_1',
|
||||
type: TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
credential_type: TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN,
|
||||
});
|
||||
const credentialLibrary2 = store.createRecord('credential-library', {
|
||||
id: 'lib_2',
|
||||
type: TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
credential_type: TYPE_CREDENTIAL_USERNAME_PASSWORD,
|
||||
});
|
||||
|
||||
const target = store.createRecord('target', {
|
||||
brokered_credential_source_ids: [{ value: 'cred_2' }],
|
||||
type: TYPE_TARGET_RDP,
|
||||
});
|
||||
|
||||
controller.set('model', {
|
||||
target,
|
||||
credentialLibraries: [credentialLibrary1, credentialLibrary2],
|
||||
credentials: [credential1],
|
||||
});
|
||||
|
||||
const filteredCredentialSources = controller.filteredCredentialSources;
|
||||
|
||||
assert.strictEqual(filteredCredentialSources.length, 3);
|
||||
assert.true(filteredCredentialSources.includes(credentialLibrary1));
|
||||
assert.true(filteredCredentialSources.includes(credentialLibrary2));
|
||||
assert.true(filteredCredentialSources.includes(credential1));
|
||||
assert.false(filteredCredentialSources.includes(credential2));
|
||||
});
|
||||
},
|
||||
);
|
||||
Reference in new issue
Block a user