Merge ~newell-jensen/maas:lp1823265 into maas:master

Proposed by Newell Jensen
Status: Merged
Approved by: Newell Jensen
Approved revision: af79431908a83cf92e0d9873b2953c26fe7a6401
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~newell-jensen/maas:lp1823265
Merge into: maas:master
Diff against target: 52 lines (+17/-5)
2 files modified
src/maasserver/static/js/angular/controllers/pod_details.js (+2/-4)
src/maasserver/static/js/angular/controllers/tests/test_pod_details.js (+15/-1)
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+367142@code.launchpad.net

Commit message

LP: #1823265 -- validate hostname for pod composition with ValidationService.validateHostname to be consistent with other areas of MAAS.

To post a comment you must log in.
Revision history for this message
Andres Rodriguez (andreserl) wrote :

lgtm! however, thsi doesn't really address the issue because if someone creates a machine via the API with a hostname with an '_', it will also result it it being allowed by the api, but failure later.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/static/js/angular/controllers/pod_details.js b/src/maasserver/static/js/angular/controllers/pod_details.js
2index 8a32b8e..938bc67 100644
3--- a/src/maasserver/static/js/angular/controllers/pod_details.js
4+++ b/src/maasserver/static/js/angular/controllers/pod_details.js
5@@ -1,4 +1,4 @@
6-/* Copyright 2017-2018 Canonical Ltd. This software is licensed under the
7+/* Copyright 2017-2019 Canonical Ltd. This software is licensed under the
8 * GNU Affero General Public License version 3 (see the file LICENSE).
9 *
10 * MAAS Pod Details Controller
11@@ -256,9 +256,7 @@ function PodDetailsController(
12
13 var hostname = $scope.compose.obj.hostname;
14
15- if (hostname && hostname.includes("_")) {
16- return false;
17- }
18+ valid = ValidationService.validateHostname(hostname);
19
20 requests.forEach(function(request) {
21 if (request.size > request.available || request.size === "") {
22diff --git a/src/maasserver/static/js/angular/controllers/tests/test_pod_details.js b/src/maasserver/static/js/angular/controllers/tests/test_pod_details.js
23index 5b053f0..db4e781 100644
24--- a/src/maasserver/static/js/angular/controllers/tests/test_pod_details.js
25+++ b/src/maasserver/static/js/angular/controllers/tests/test_pod_details.js
26@@ -1,4 +1,4 @@
27-/* Copyright 2017-2018 Canonical Ltd. This software is licensed under the
28+/* Copyright 2017-2019 Canonical Ltd. This software is licensed under the
29 * GNU Affero General Public License version 3 (see the file LICENSE).
30 *
31 * Unit tests for PodDetailsController.
32@@ -560,6 +560,20 @@ describe("PodDetailsController", function() {
33 });
34 });
35
36+ describe("validateMachineCompose", function() {
37+ it("returns true for valid hostname", function() {
38+ makeController();
39+ $scope.compose.obj.hostname = "testing-hostname";
40+ expect($scope.validateMachineCompose()).toBe(true);
41+ });
42+
43+ it("returns false for invalid hostname", function() {
44+ makeController();
45+ $scope.compose.obj.hostname = "testing_hostname";
46+ expect($scope.validateMachineCompose()).toBe(false);
47+ });
48+ });
49+
50 describe("totalStoragePercentage", function() {
51 it("returns the correct percentage", function() {
52 makeController();

Subscribers

People subscribed via source and target branches