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

Fix multi-tab endpoint credential validation by passing the right credential type when user hits "Enter" #4768

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 @@ -674,9 +674,8 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
}
};

$scope.validateClicked = function($event, authType, formSubmit) {
$scope.authType = authType;
miqService.validateWithREST($event, authType, $scope.actionUrl, formSubmit)
$scope.validateClicked = function($event, _authType, formSubmit) {
miqService.validateWithREST($event, $scope.currentTab, $scope.actionUrl, formSubmit)
.then(function success(data) {
// check if data object is a JSON, otherwise (recieved JS or HTML) output a warning to the user.
if (data === Object(data)) {
Expand All @@ -699,7 +698,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
};

$scope.updateAuthStatus = function(updatedValue) {
$scope.angularForm[$scope.authType + '_auth_status'].$setViewValue(updatedValue);
$scope.angularForm[$scope.currentTab + '_auth_status'].$setViewValue(updatedValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AparnaKarve that change causes the 'virtualization' tab of the Container provider to fail.
$scope.authType returns kubevirt, which $scope.currentTab returns 'virtualization`.

There is kubevirt_auth_status but there isn't virtualization_auth_status, therefore attempt to validate the virtualization tab fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@masayag Is this just a matter of renaming the virtualization tab to kubevirt?
Is it OK if we rename the tab to kubevirt? Because $scope.currentTab needs to match with the tab name that is specified in the haml.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AparnaKarve ack from my side for renaming the tab.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@masayag Thanks!
Would you be able to test my rename tab changes here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR works fine for editing the Container Provider and for enabling the 'Virtualization' tab
However, we do allow user to view & change token for the Kubevirt provider under Infra --> Providers --> Edit
and that fails with the shown error in the screenshot:

selection_869

the value of: ManageIQ.angular.scope.angularForm['default_auth_status'] is:
undefined
in this context, this one works: ManageIQ.angular.scope.angularForm['kubevirt_auth_status'].$setViewValue(true)
which isn't the conventional way it works for other providers - therefore we can just disable that option on this dialog and not allow changing the token(password) in this context, only under the virtualization tab.

So this PR fixes the blocked functionality of adding kubevirt provider and one gap to close.
I think this PR should be merged and the other issue should be addressed separately.

};

$scope.updateHostname = function(value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('emsCommonFormController', function() {
spyOn(miqService, 'sparkleOn');
spyOn(miqService, 'sparkleOff');
spyOn(API, 'options').and.callFake(function(url){ return Promise.resolve({}); });
spyOn(miqService, 'validateWithREST').and.callFake(function(url){ return Promise.resolve({}); });
$scope = $rootScope.$new();

var emsCommonFormResponse = {
Expand Down Expand Up @@ -369,6 +370,23 @@ describe('emsCommonFormController', function() {
});
});

describe('#validateClicked', function() {
beforeEach(function() {
$httpBackend.flush();
$scope.currentTab = "console";
$scope.actionUrl = "/xyz";
$scope.validateClicked($.Event, "default", true);
});

it('turns the spinner on via the miqService', function() {
expect(miqService.sparkleOn).toHaveBeenCalled();
});

it('delegates to miqService.validateClicked', function() {
expect(miqService.validateWithREST).toHaveBeenCalledWith($.Event, "console", "/xyz", true);
});
});

describe('Validates credential fields', function() {
beforeEach(function() {
$httpBackend.flush();
Expand Down