You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2021/01/28 22:36:40 UTC
[trafficcontrol] branch master updated: Added logic for resending
registration for new-user (#5442)
This is an automated email from the ASF dual-hosted git repository.
mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 523a357 Added logic for resending registration for new-user (#5442)
523a357 is described below
commit 523a3577819c59aea5bf8b3275c344452c081ed4
Author: Rima Shah <22...@users.noreply.github.com>
AuthorDate: Thu Jan 28 15:36:24 2021 -0700
Added logic for resending registration for new-user (#5442)
* Added logic for resending registration for new-user
* Made Registration field readonly
* Added a check for registration_sent field
* Added API test cases for users and added button names on user table
* Updated TP's user test cases.
* Updated changelog statement.
* Added Registration Sent column to user tables
* Added helptext for registration sent. Updated test case to check for readonly and not disabled attribute. Removed unused button name.
---
CHANGELOG.md | 1 +
.../form/user/edit/FormEditUserController.js | 14 +++-
.../common/modules/form/user/form.user.tpl.html | 14 +++-
.../capabilityUsers/table.capabilityUsers.tpl.html | 2 +
.../table/roleUsers/table.roleUsers.tpl.html | 2 +
.../table/tenantUsers/table.tenantUsers.tpl.html | 2 +
.../modules/table/users/TableUsersController.js | 3 +-
.../modules/table/users/table.users.tpl.html | 10 ++-
traffic_portal/test/end_to_end/conf.json | 3 +-
traffic_portal/test/end_to_end/users/pageData.js | 34 +++++++++
traffic_portal/test/end_to_end/users/users-spec.js | 88 ++++++++++++++++++++++
11 files changed, 165 insertions(+), 8 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ac05294..fa12261 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## [unreleased]
### Added
+- Traffic Portal: [#5340](https://github.com/apache/trafficcontrol/issues/5340) - Added the ability to resend a user registration from user screen.
- Traffic Portal: [#5394](https://github.com/apache/trafficcontrol/issues/5394) - Converts the tenant table to a tenant tree for usability
- Traffic Portal: upgraded delivery service UI tables to use more powerful/performant ag-grid component
- Traffic Ops: added a feature so that the user can specify `maxRequestHeaderBytes` on a per delivery service basis
diff --git a/traffic_portal/app/src/common/modules/form/user/edit/FormEditUserController.js b/traffic_portal/app/src/common/modules/form/user/edit/FormEditUserController.js
index 2ef4c0d..73ba3c0 100644
--- a/traffic_portal/app/src/common/modules/form/user/edit/FormEditUserController.js
+++ b/traffic_portal/app/src/common/modules/form/user/edit/FormEditUserController.js
@@ -30,6 +30,14 @@ var FormEditUserController = function(user, $scope, $controller, $uibModal, $anc
});
};
+ var sendRegistration = function(user) {
+ userService.registerUser(user).
+ then(function() {
+ $scope.userEmail = angular.copy(user.email);
+ $anchorScroll(); // scrolls window to top
+ });
+ };
+
$scope.userName = angular.copy(user.username);
$scope.settings = {
@@ -37,10 +45,14 @@ var FormEditUserController = function(user, $scope, $controller, $uibModal, $anc
saveLabel: 'Update'
};
- $scope.confirmSave = function(user, usernameField) {
+ $scope.confirmSave = function(user) {
saveUser(user);
};
+ $scope.resendRegistration = function(user) {
+ sendRegistration(user);
+ };
+
};
FormEditUserController.$inject = ['user', '$scope', '$controller', '$uibModal', '$anchorScroll', 'locationUtils', 'userService'];
diff --git a/traffic_portal/app/src/common/modules/form/user/form.user.tpl.html b/traffic_portal/app/src/common/modules/form/user/form.user.tpl.html
index a46a0f6..3e85609 100644
--- a/traffic_portal/app/src/common/modules/form/user/form.user.tpl.html
+++ b/traffic_portal/app/src/common/modules/form/user/form.user.tpl.html
@@ -105,8 +105,20 @@ under the License.
<textarea name="publicSshKey" rows="5" class="form-control" ng-model="user.publicSshKey"></textarea>
</div>
</div>
+ <div class="form-group" ng-if="!settings.isNew" ng-class="{'has-error': hasError(userForm.registrationSent), 'has-feedback': hasError(userForm.registrationSent)}">
+ <label class="has-tooltip control-label col-md-2 col-sm-2 col-xs-12">Registration Sent<div class="helptooltip">
+ <div class="helptext">The date on which a registration email was sent to create this user. The value is blank if the user was not created via a new user registration.</div>
+ </div>
+ </label>
+ <div class="col-md-10 col-sm-10 col-xs-12">
+ <input name="registrationSent" type="text" class="form-control" ng-model="user.registrationSent" ng-maxlength="128" readonly>
+ <span ng-show="hasError(userForm.registrationSent)" class="form-control-feedback"><i class="fa fa-times"></i></span>
+ </div>
+ </div>
+
<div class="modal-footer">
- <button type="button" class="btn btn-success" ng-disabled="userForm.$pristine || userForm.$invalid" ng-click="confirmSave(user, userForm.uName)">{{settings.saveLabel}}</button>
+ <button ng-if="user.newUser" type="button" class="btn btn-default" ng-click="resendRegistration(user)">Resend Registration</button>
+ <button type="button" class="btn btn-success" ng-disabled="userForm.$pristine || userForm.$invalid" ng-click="confirmSave(user)">{{settings.saveLabel}}</button>
</div>
</form>
</div>
diff --git a/traffic_portal/app/src/common/modules/table/capabilityUsers/table.capabilityUsers.tpl.html b/traffic_portal/app/src/common/modules/table/capabilityUsers/table.capabilityUsers.tpl.html
index 2e9a21c..d3a3687 100644
--- a/traffic_portal/app/src/common/modules/table/capabilityUsers/table.capabilityUsers.tpl.html
+++ b/traffic_portal/app/src/common/modules/table/capabilityUsers/table.capabilityUsers.tpl.html
@@ -52,6 +52,7 @@ under the License.
<th>Email</th>
<th>Tenant</th>
<th>Role</th>
+ <th>Registration Sent</th>
</tr>
</thead>
<tbody>
@@ -61,6 +62,7 @@ under the License.
<td data-search="^{{::u.email}}$">{{::u.email}}</td>
<td data-search="^{{::u.tenant}}$">{{::u.tenant}}</td>
<td data-search="^{{::u.rolename}}$">{{::u.rolename}}</td>
+ <td data-search="^{{::u.registrationSent}}$">{{::u.registrationSent}}</td>
</tr>
</tbody>
</table>
diff --git a/traffic_portal/app/src/common/modules/table/roleUsers/table.roleUsers.tpl.html b/traffic_portal/app/src/common/modules/table/roleUsers/table.roleUsers.tpl.html
index 32bc26d..53c8420 100644
--- a/traffic_portal/app/src/common/modules/table/roleUsers/table.roleUsers.tpl.html
+++ b/traffic_portal/app/src/common/modules/table/roleUsers/table.roleUsers.tpl.html
@@ -52,6 +52,7 @@ under the License.
<th>Email</th>
<th>Tenant</th>
<th>Role</th>
+ <th>Registration Sent</th>
</tr>
</thead>
<tbody>
@@ -61,6 +62,7 @@ under the License.
<td data-search="^{{::u.email}}$">{{::u.email}}</td>
<td data-search="^{{::u.tenant}}$">{{::u.tenant}}</td>
<td data-search="^{{::u.rolename}}$">{{::u.rolename}}</td>
+ <td data-search="^{{::u.registrationSent}}$">{{::u.registrationSent}}</td>
</tr>
</tbody>
</table>
diff --git a/traffic_portal/app/src/common/modules/table/tenantUsers/table.tenantUsers.tpl.html b/traffic_portal/app/src/common/modules/table/tenantUsers/table.tenantUsers.tpl.html
index 8e063e9..f86a8ff 100644
--- a/traffic_portal/app/src/common/modules/table/tenantUsers/table.tenantUsers.tpl.html
+++ b/traffic_portal/app/src/common/modules/table/tenantUsers/table.tenantUsers.tpl.html
@@ -52,6 +52,7 @@ under the License.
<th>Email</th>
<th>Tenant</th>
<th>Role</th>
+ <th>Registration Sent</th>
</tr>
</thead>
<tbody>
@@ -61,6 +62,7 @@ under the License.
<td data-search="^{{::u.email}}$">{{::u.email}}</td>
<td data-search="^{{::u.tenant}}$">{{::u.tenant}}</td>
<td data-search="^{{::u.rolename}}$">{{::u.rolename}}</td>
+ <td data-search="^{{::u.registrationSent}}$">{{::u.registrationSent}}</td>
</tr>
</tbody>
</table>
diff --git a/traffic_portal/app/src/common/modules/table/users/TableUsersController.js b/traffic_portal/app/src/common/modules/table/users/TableUsersController.js
index f887576..8d39852 100644
--- a/traffic_portal/app/src/common/modules/table/users/TableUsersController.js
+++ b/traffic_portal/app/src/common/modules/table/users/TableUsersController.js
@@ -28,7 +28,8 @@ var TableUsersController = function(users, $scope, $state, locationUtils) {
{ "name": "Username", "visible": true, "searchable": true },
{ "name": "Email", "visible": true, "searchable": true },
{ "name": "Tenant", "visible": true, "searchable": true },
- { "name": "Role", "visible": true, "searchable": true }
+ { "name": "Role", "visible": true, "searchable": true },
+ { "name": "Registration Sent", "visible": false, "searchable": true }
];
$scope.editUser = function(id) {
diff --git a/traffic_portal/app/src/common/modules/table/users/table.users.tpl.html b/traffic_portal/app/src/common/modules/table/users/table.users.tpl.html
index 0fabd99..4780796 100644
--- a/traffic_portal/app/src/common/modules/table/users/table.users.tpl.html
+++ b/traffic_portal/app/src/common/modules/table/users/table.users.tpl.html
@@ -23,8 +23,8 @@ under the License.
<li class="active">Users</li>
</ol>
<div class="pull-right">
- <button class="btn btn-primary" title="Register New User" ng-click="register()">Register User</button>
- <button class="btn btn-primary" title="Create New User" ng-click="create()"><i class="fa fa-plus"></i></button>
+ <button name="createRegisterUserButton" class="btn btn-primary" title="Register New User" ng-click="register()">Register User</button>
+ <button name="createUserButton" class="btn btn-primary" title="Create New User" ng-click="create()"><i class="fa fa-plus"></i></button>
<button class="btn btn-default" title="Refresh" ng-click="refresh()"><i class="fa fa-refresh"></i></button>
<div id="toggleColumns" class="btn-group" role="group" title="Select Table Columns" uib-dropdown is-open="columnSettings.isopen">
<button type="button" class="btn btn-default dropdown-toggle" uib-dropdown-toggle aria-haspopup="true" aria-expanded="false">
@@ -52,15 +52,17 @@ under the License.
<th>Email</th>
<th>Tenant</th>
<th>Role</th>
+ <th>Registration Sent</th>
</tr>
</thead>
<tbody>
<tr ng-click="editUser(u.id)" ng-repeat="u in ::users">
<td data-search="^{{::u.fullName}}$">{{::u.fullName}}</td>
- <td data-search="^{{::u.username}}$">{{::u.username}}</td>
- <td data-search="^{{::u.email}}$">{{::u.email}}</td>
+ <td name="username" data-search="^{{::u.username}}$">{{::u.username}}</td>
+ <td name="email" data-search="^{{::u.email}}$">{{::u.email}}</td>
<td data-search="^{{::u.tenant}}$">{{::u.tenant}}</td>
<td data-search="^{{::u.rolename}}$">{{::u.rolename}}</td>
+ <td data-search="^{{::u.registrationSent}}$">{{::u.registrationSent}}</td>
</tr>
</tbody>
</table>
diff --git a/traffic_portal/test/end_to_end/conf.json b/traffic_portal/test/end_to_end/conf.json
index 64f39a1..b5bb3f8 100644
--- a/traffic_portal/test/end_to_end/conf.json
+++ b/traffic_portal/test/end_to_end/conf.json
@@ -28,7 +28,8 @@
"topologies/topologies-spec.js",
"deliveryServices/delivery-services-spec.js",
"jobs/jobs-spec.js",
- "tenants/tenants-spec.js"
+ "tenants/tenants-spec.js",
+ "users/users-spec.js"
]
}
}
diff --git a/traffic_portal/test/end_to_end/users/pageData.js b/traffic_portal/test/end_to_end/users/pageData.js
new file mode 100644
index 0000000..b8dda9f
--- /dev/null
+++ b/traffic_portal/test/end_to_end/users/pageData.js
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+module.exports = function(){
+ this.username=element(by.name('uName'));
+ this.fullName=element(by.name('fullName'));
+ this.email=element(by.name('email'));
+ this.roleName=element(by.name('role'));
+ this.tenantId=element(by.name('tenantId'));
+ this.localPasswd=element(by.name('uPass'));
+ this.confirmLocalPasswd=element(by.name('confirmPassword'));
+ this.registerSent=element(by.name('registrationSent'));
+ this.createButton=element(by.buttonText('Create'));
+ this.registerNewUserButton=element(by.name('createRegisterUserButton'));
+ this.registerEmailButton=element(by.buttonText('Send Registration'));
+ this.updateButton=element(by.buttonText('Update'));
+ this.searchFilter=element(by.id('usersTable_filter')).element(by.css('label input'));
+};
diff --git a/traffic_portal/test/end_to_end/users/users-spec.js b/traffic_portal/test/end_to_end/users/users-spec.js
index cedeb6f..382fca8 100644
--- a/traffic_portal/test/end_to_end/users/users-spec.js
+++ b/traffic_portal/test/end_to_end/users/users-spec.js
@@ -17,10 +17,21 @@
* under the License.
*/
+var pd = require('./pageData.js');
var cfunc = require('../common/commonFunctions.js');
describe('Traffic Portal Users Test Suite', function() {
+ const pageData = new pd();
const commonFunctions = new cfunc();
+ const myNewUser = {
+ username: 'user-' + commonFunctions.shuffle('abcdefghijklmonpqrstuvwxyz0123456789'),
+ fullName: 'test-' + commonFunctions.shuffle('abcdefghijklmonpqrstuvwxyz0123456789'),
+ email: 'test@cdn.' + commonFunctions.shuffle('abcdefghijklmonpqrstuvwxyz') + '.com',
+ localPasswd: commonFunctions.shuffle('abcdefghijklmonpqrstuvwxyz'),
+ };
+ const myNewRegisteredUser = {
+ email: 'test1@cdn.' + commonFunctions.shuffle('abcdefghijklmonpqrstuvwxyz') + '.com'
+ };
it('should go to the users page', function() {
console.log("Go to the users page");
@@ -41,6 +52,83 @@ describe('Traffic Portal Users Test Suite', function() {
expect(first.isSelected()).toBe(false);
let tableColumns = element.all(by.css('#usersTable tr:first-child td'));
expect(tableColumns.count()).toBe(4);
+ first.click();
+ });
+
+ it('should open new users form page', function() {
+ console.log("Open new users form page");
+ browser.driver.findElement(by.name('createUserButton')).click();
+ expect(browser.getCurrentUrl().then(commonFunctions.urlPath)).toEqual(commonFunctions.urlPath(browser.baseUrl)+"#!/users/new");
+ });
+
+ it('should create a new user', function () {
+ console.log("Creating a new user");
+ expect(pageData.createButton.isEnabled()).toBe(false);
+ pageData.username.sendKeys(myNewUser.username);
+ pageData.fullName.sendKeys(myNewUser.fullName);
+ pageData.email.sendKeys(myNewUser.email);
+ commonFunctions.selectDropdownbyNum(pageData.roleName, 1);
+ commonFunctions.selectDropdownbyNum(pageData.tenantId, 1);
+ pageData.localPasswd.sendKeys(myNewUser.localPasswd);
+ pageData.confirmLocalPasswd.sendKeys(myNewUser.localPasswd);
+ expect(pageData.createButton.isEnabled()).toBe(true);
+ pageData.createButton.click();
+ expect(browser.getCurrentUrl().then(commonFunctions.urlPath)).toEqual(commonFunctions.urlPath(browser.baseUrl)+"#!/users");
+ });
+
+ it('should update a user', function() {
+ console.log('Updating the new user: ' + myNewUser.username);
+ browser.sleep(250);
+ pageData.searchFilter.sendKeys(myNewUser.username);
+ browser.sleep(250);
+ element.all(by.repeater('u in ::users')).filter(function(row){
+ return row.element(by.name('username')).getText().then(function(val){
+ return val === myNewUser.username;
+ });
+ }).get(0).click();
+ browser.sleep(1000);
+ pageData.fullName.clear();
+ pageData.fullName.sendKeys(myNewUser.fullName + ' updated');
+ pageData.updateButton.click();
+ expect(pageData.fullName.getText() === myNewUser.fullName + ' updated');
+ });
+
+ it('should open new registered users form page', function() {
+ console.log("Open new register users form page");
+ browser.setLocation("users");
+ pageData.registerNewUserButton.click();
+ expect(browser.getCurrentUrl().then(commonFunctions.urlPath)).toEqual(commonFunctions.urlPath(browser.baseUrl)+"#!/users/register");
+ });
+
+ it('should create a new registered user', function () {
+ console.log("Creating a new registered user");
+ expect(pageData.registerEmailButton.isEnabled()).toBe(false);
+ pageData.email.sendKeys(myNewRegisteredUser.email);
+ commonFunctions.selectDropdownbyNum(pageData.roleName, 2);
+ commonFunctions.selectDropdownbyNum(pageData.tenantId, 2);
+ expect(pageData.registerEmailButton.isEnabled()).toBe(true);
+ pageData.registerEmailButton.click();
+ expect(browser.getCurrentUrl().then(commonFunctions.urlPath)).toEqual(commonFunctions.urlPath(browser.baseUrl)+"#!/users/register");
+ });
+
+ it('should update a new registered user', function() {
+ console.log('Updating the new registered user: ' + myNewRegisteredUser.email);
+ browser.setLocation("users");
+ pageData.searchFilter.clear();
+ browser.sleep(250);
+ pageData.searchFilter.sendKeys(myNewRegisteredUser.email);
+ browser.sleep(250);
+ element.all(by.repeater('u in ::users')).filter(function(row){
+ return row.element(by.name('email')).getText().then(function(val){
+ return val === myNewRegisteredUser.email;
+ });
+ }).get(0).click();
+ browser.sleep(1000);
+ pageData.fullName.clear();
+ pageData.fullName.sendKeys('test1 updated');
+ expect(pageData.registerSent.getAttribute('readOnly')).toBe('true');
+ pageData.updateButton.click();
+ expect(pageData.fullName.getText() === 'test1 updated');
});
});