URL: https://github.com/freeipa/freeipa/pull/2288
Author: serg-cymbaluk
 Title: #2288: [Backport][ipa-4-7] Fix translation of migration pages
Action: opened

PR body:
"""
This PR was opened automatically because PR #2157 was pushed to master and 
backport to ipa-4-7 is required.
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/2288/head:pr2288
git checkout pr2288
From 5e119fa7a2d689fa95ed585505b913f8755f1235 Mon Sep 17 00:00:00 2001
From: Stanislav Levin <s...@altlinux.org>
Date: Sat, 14 Jul 2018 12:41:35 +0300
Subject: [PATCH 1/8] Add MigrateScreen widget

This widget is intended to integrate password migrate page into the
entire IPA Web framework. The functionality is the same as mentioned
standalone "ipa/migration/index.html".

Fixes: https://pagure.io/freeipa/issue/7641
---
 install/ui/src/freeipa/config.js              |   5 +
 .../ui/src/freeipa/widgets/MigrateScreen.js   | 199 ++++++++++++++++++
 2 files changed, 204 insertions(+)
 create mode 100644 install/ui/src/freeipa/widgets/MigrateScreen.js

diff --git a/install/ui/src/freeipa/config.js b/install/ui/src/freeipa/config.js
index 9825dffadf..14e80956e5 100644
--- a/install/ui/src/freeipa/config.js
+++ b/install/ui/src/freeipa/config.js
@@ -48,6 +48,11 @@ define([
          */
         i18n_messages_url: '/ipa/i18n_messages',
 
+        /**
+         * password migration url
+         */
+        migration_url: '/ipa/migration/migration.py',
+
         /**
          * RPC url
          */
diff --git a/install/ui/src/freeipa/widgets/MigrateScreen.js b/install/ui/src/freeipa/widgets/MigrateScreen.js
new file mode 100644
index 0000000000..0f005d4be2
--- /dev/null
+++ b/install/ui/src/freeipa/widgets/MigrateScreen.js
@@ -0,0 +1,199 @@
+//
+// Copyright (C) 2018  FreeIPA Contributors see COPYING for license
+//
+
+define(['dojo/_base/declare',
+    'dojo/dom-construct',
+    'dojo/topic',
+    '../ipa',
+    '../config',
+    '../text',
+    '../util',
+    './LoginScreenBase'
+    ],
+    function(declare, construct, topic, IPA, config, text, util,
+        LoginScreenBase) {
+
+        /**
+         * Widget with password migration form.
+         *
+         * Supported operations:
+         *
+         * - password migration
+         *
+         * @class widgets.MigrateScreen
+         */
+        var MigrateScreen = declare([LoginScreenBase], {
+
+            migration_error_msg: "There was a problem with your request."+
+            "Please, try again later.",
+
+            migration_failure_msg: "Password migration was not successful",
+
+            migration_info_msg: "<h1>Password Migration</h1><p>"+
+            "If you have been sent here by your administrator, your personal "+
+            "information is being migrated to a new identity management "+
+            "solution (IPA).</p><p>Please, enter your credentials in the form"+
+            " to complete the process. Upon successful login your kerberos "+
+            "account will be activated.</p>",
+
+            migration_invalid_password: "The password or username you entered"+
+            " is incorrect",
+
+            migration_success: "Password migration was successful",
+
+            //nodes:
+            migrate_btn_node: null,
+
+            render_buttons: function(container) {
+                this.migrate_btn_node = IPA.button({
+                    label: text.get('@i18n:buttons.migrate', "Migrate"),
+                    'class': 'btn-primary btn-lg',
+                    click: this.on_confirm.bind(this)
+                })[0];
+                construct.place(this.migrate_btn_node, container);
+            },
+
+            on_confirm: function() {
+                this.migrate();
+            },
+
+            migrate: function() {
+                var val_summary = this.get_widget('validation');
+                val_summary.remove('migrate');
+
+                if (!this.validate()) return;
+
+                var username = this.get_field('username');
+                var psw = this.get_field('password');
+                var result = this.migrate_core(
+                    username.get_value()[0],
+                    psw.get_value()[0]);
+
+                psw.set_value('');
+                if (result.status === 'ok') {
+                    val_summary.add_success('migrate', this.migration_success);
+                    window.setTimeout(this.redirect, 3000);
+                } else {
+                    val_summary.add_error('migrate', result.message);
+                }
+            },
+
+            redirect: function() {
+                window.location = config.url;
+            },
+
+            migrate_core: function(username, password) {
+
+                //possible results: 'ok', 'invalid-password', 'migration-error'
+
+                var status = 'invalid';
+                var result = {
+                    status: status,
+                    message: this.migration_failure_msg
+                };
+
+                function success_handler(data, text_status, xhr) {
+                    topic.publish('rpc-end');
+                    result.status = xhr.getResponseHeader(
+                        "X-IPA-Migrate-Result") || status;
+
+                    if (result.status === 'migration-error') {
+                        result.message = this.migration_error_msg;
+                    } else if (result.status === 'invalid-password') {
+                        result.message = this.migration_invalid_password;
+                    }
+                    return result;
+                }
+
+                function error_handler(xhr, text_status, error_thrown) {
+                    topic.publish('rpc-end');
+                    return result;
+                }
+
+                var data = {
+                    username: username,
+                    password: password
+                };
+
+                var request = {
+                    url: config.migration_url,
+                    data: data,
+                    contentType: 'application/x-www-form-urlencoded',
+                    processData: true,
+                    dataType: 'html',
+                    async: false,
+                    type: 'POST',
+                    success: success_handler.bind(this),
+                    error: error_handler.bind(this)
+                };
+
+                topic.publish('rpc-start');
+                $.ajax(request);
+
+                return result;
+            },
+
+            refresh: function() {
+                this.set('aside', this.migration_info_msg);
+                var val_summary = this.get_widget('validation');
+
+                var u_f = this.fields.get('username');
+                this.get_widget('username').focus_input();
+            },
+
+            constructor: function(spec) {
+                spec = spec || {};
+
+                this.migration_error_msg = text.get(
+                    spec.migration_error_msg ||
+                        '@i18n:migration.migration_error_msg',
+                        this.migration_error_msg);
+
+                this.migration_failure_msg = text.get(
+                    spec.migration_failure_msg ||
+                        '@i18n:migration.migration_failure_msg',
+                        this.migration_failure_msg);
+
+                this.migration_info_msg = text.get(
+                    spec.migration_info_msg ||
+                        '@i18n:migration.migration_info_msg',
+                        this.migration_info_msg);
+
+                this.migration_invalid_password = text.get(
+                    spec.migration_invalid_password ||
+                        '@i18n:migration.migration_invalid_password',
+                        this.migration_invalid_password);
+
+                this.migration_success = text.get(
+                    spec.migration_success ||
+                        '@i18n:migration.migration_success',
+                        this.migration_success);
+
+                this.field_specs = MigrateScreen.field_specs;
+            }
+        });
+
+        MigrateScreen.field_specs = [
+            {
+                $type: 'text',
+                name: 'username',
+                label: text.get('@i18n:login.username', "Username"),
+                placeholder: text.get('@i18n:login.username', "Username"),
+                required: true,
+                show_errors: false,
+                undo: false
+            },
+            {
+                $type: 'password',
+                name: 'password',
+                label: text.get('@i18n:login.password', "Password"),
+                placeholder: text.get('@i18n:login.password', 'Password'),
+                required: true,
+                show_errors: false,
+                undo: false
+            }
+        ];
+
+        return MigrateScreen;
+    });

From 2aa675c4fb2b79f52307dc7eee76dd1261ae8ed4 Mon Sep 17 00:00:00 2001
From: Stanislav Levin <s...@altlinux.org>
Date: Sat, 14 Jul 2018 13:07:47 +0300
Subject: [PATCH 2/8] Add "migrate" Web UI plugin

This plugin creates and registers a facet with password migrate page.

Fixes: https://pagure.io/freeipa/issue/7641
---
 install/ui/src/freeipa/plugins/migrate.js | 72 +++++++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 install/ui/src/freeipa/plugins/migrate.js

diff --git a/install/ui/src/freeipa/plugins/migrate.js b/install/ui/src/freeipa/plugins/migrate.js
new file mode 100644
index 0000000000..e3613c13aa
--- /dev/null
+++ b/install/ui/src/freeipa/plugins/migrate.js
@@ -0,0 +1,72 @@
+//
+// Copyright (C) 2018  FreeIPA Contributors see COPYING for license
+//
+
+define([
+    'dojo/_base/declare',
+    'dojo/on',
+    '../facets/Facet',
+    '../phases',
+    '../reg',
+    '../text',
+    '../widget',
+    '../widgets/MigrateScreen'
+    ],
+    function(declare, on, Facet, phases, reg, text, widget, MigrateScreen) {
+
+        /**
+         * Migrate Facet plugin
+         *
+         * Creates and registers a facet with migrate page.
+         *
+         * @class plugins.migrate
+         * @singleton
+         */
+        var migrate = {};
+
+        migrate.facet_spec = {
+            name: 'migrate',
+            'class': 'login-pf-body',
+            preferred_container: 'simple',
+            requires_auth: false,
+            widgets: [
+                {
+                    $type: 'activity',
+                    name: 'activity',
+                    text: text.get('@i18n:migration.migrating', 'Migrating'),
+                    visible: false
+                },
+                {
+                    $type: 'migrate_screen',
+                    name: 'migrate_screen'
+                }
+            ]
+        };
+
+        migrate.MigrateFacet = declare([Facet], {
+            init: function() {
+                this.inherited(arguments);
+                var migrate_screen = this.get_widget('migrate_screen');
+                var self = this;
+
+                on(this, 'show', function(args) {
+                    migrate_screen.refresh();
+                });
+            }
+        });
+
+        phases.on('registration', function() {
+            var fa = reg.facet;
+            var w = reg.widget;
+
+            w.register('migrate_screen', MigrateScreen);
+
+            fa.register({
+                type: 'migrate',
+                factory: migrate.MigrateFacet,
+                spec: migrate.facet_spec
+            });
+        });
+
+        return migrate;
+    });

From 61bd28f1f0111346850db158378cea52cf1a550a Mon Sep 17 00:00:00 2001
From: Stanislav Levin <s...@altlinux.org>
Date: Sat, 14 Jul 2018 13:18:57 +0300
Subject: [PATCH 3/8] Return the result of "password migration" procedure

So far "migration" end point redirected to "error"/"invalid" page as
a result of the client request. To use ajax requests and to not
reload/load the whole page the response should include the result of
request.

Fixes: https://pagure.io/freeipa/issue/7641
---
 install/migration/migration.py | 43 ++++++++++++++++++++++------------
 1 file changed, 28 insertions(+), 15 deletions(-)

diff --git a/install/migration/migration.py b/install/migration/migration.py
index 9aace8c077..9b614fc9fc 100644
--- a/install/migration/migration.py
+++ b/install/migration/migration.py
@@ -25,7 +25,6 @@
 import errno
 import logging
 import os.path
-from wsgiref.util import request_uri
 
 from ipaplatform.paths import paths
 from ipapython.dn import DN
@@ -35,18 +34,21 @@
 logger = logging.getLogger(os.path.basename(__file__))
 
 
+def bad_request(start_response):
+    """
+    Return a 400 Bad Request error.
+    """
+    status = '400 Bad Request'
+    response_headers = []
+    response = b''
+
+    start_response(status, response_headers)
+    return [response]
+
 def wsgi_redirect(start_response, loc):
     start_response('302 Found', [('Location', loc)])
     return []
 
-def get_ui_url(environ):
-    full_url = request_uri(environ)
-    index = full_url.rfind(environ.get('SCRIPT_NAME',''))
-    if index == -1:
-        raise ValueError('Cannot strip the script URL from full URL "%s"' % full_url)
-    return full_url[:index] + "/ipa/ui"
-
-
 def bind(ldap_uri, base_dn, username, password):
     if not base_dn:
         logger.error('migration unable to get base dn')
@@ -71,9 +73,18 @@ def application(environ, start_response):
     if environ.get('REQUEST_METHOD', None) != 'POST':
         return wsgi_redirect(start_response, 'index.html')
 
+    content_type = environ.get('CONTENT_TYPE', '').lower()
+    if not content_type.startswith('application/x-www-form-urlencoded'):
+        return bad_request(start_response)
+
     form_data = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)
     if 'username' not in form_data or 'password' not in form_data:
-        return wsgi_redirect(start_response, 'invalid.html')
+        return bad_request(start_response)
+
+    status = '200 Success'
+    response_headers = []
+    result = 'error'
+    response = b''
 
     # API object only for configuration, finalize() not needed
     api = create_api(mode=None)
@@ -83,9 +94,11 @@ def application(environ, start_response):
              form_data['username'].value, form_data['password'].value)
     except IOError as err:
         if err.errno == errno.EPERM:
-            return wsgi_redirect(start_response, 'invalid.html')
+            result = 'invalid-password'
         if err.errno == errno.EIO:
-            return wsgi_redirect(start_response, 'error.html')
-
-    ui_url = get_ui_url(environ)
-    return wsgi_redirect(start_response, ui_url)
+            result = 'migration-error'
+    else:
+        result = 'ok'
+    response_headers.append(('X-IPA-Migrate-Result', result))
+    start_response(status, response_headers)
+    return [response]

From 403a94940f7b0d0daae4a67e9a50f5b879cef986 Mon Sep 17 00:00:00 2001
From: Stanislav Levin <s...@altlinux.org>
Date: Sat, 14 Jul 2018 13:52:47 +0300
Subject: [PATCH 4/8] Integrate "migration" page to IPA Web framework.

To use all advantages of entire Web framework the "migration" page
should use "migrate" plugin. As well this allows to use IPA
translations.

Fixes: https://pagure.io/freeipa/issue/7641
---
 install/migration/index.html   | 115 ++++++++++++++++-----------------
 install/ui/src/freeipa/core.js |   5 +-
 2 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/install/migration/index.html b/install/migration/index.html
index 302eca263f..7cdd6e38a1 100644
--- a/install/migration/index.html
+++ b/install/migration/index.html
@@ -1,70 +1,69 @@
 <!DOCTYPE html>
-<html class="login-pf">
+<html>
 <head>
 <meta charset="utf-8">
     <title>IPA: Identity Policy Audit</title>
 
-    <link rel="stylesheet" type="text/css" href="../ui/css/patternfly.css" />
-    <link rel="stylesheet" type="text/css" href="../ui/css/ipa.css" />
-    <link rel="stylesheet" type="text/css" href="../ui/ipa.css" />
-</head>
+    <!--[if IE]>
+    <meta id="ie-detector">
+    <![endif]-->
 
-<body>
-<div class="login-pf-body">
-<span id="badge">
-    <img src="../ui/images/login-screen-logo.png" alt="" />
-</span>
-<div class="container">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <base href="../ui/" target="_blank">
+    <script type="text/javascript" src="js/libs/loader.js"></script>
+    <script type="text/javascript">
+        var dojoConfig = {
+            baseUrl: "js",
+            has: {
+                'dojo-firebug': false,
+                'dojo-debug-messages': true
+            },
+            parseOnLoad: false,
+            async: true,
+            packages: [
+                {
+                    name:'dojo',
+                    location:'dojo'
+                },
+                {
+                    name: 'freeipa',
+                    location: 'freeipa'
+                }
+            ],
+            cacheBust: ipa_loader.num_version || ""
+        };
 
-<div class="row">
+        (function() {
+            var ie = !!document.getElementById('ie-detector');
+            var styles = [
+		    'css/patternfly.css',
+		    'css/ipa.css',
+		    'ipa.css'
+	    ];
+            if (ie) styles.push('ie.css');
+            var icons = ['favicon.ico'];
+            var scripts = [
+                'js/libs/jquery.js',
+                'js/libs/jquery.ordered-map.js',
+                'js/dojo/dojo.js'
+            ];
+            ipa_loader.scripts(scripts, function() {
+                require([
+                    'freeipa/core',
+                    'dojo/domReady!'
+                    ], function(app) {
+                        app.run_simple('migrate');
+                    });
+            });
+            ipa_loader.styles(styles);
+            ipa_loader.icons(icons);
 
-    <div class="col-sm-12">
-      <div id="brand">
-        <img src="../ui/images/product-name.png" alt="">
-      </div>
-    </div>
+	})();
+    </script>
+</head>
 
-    <div class="col-sm-7 col-md-6 col-lg-5 login">
-        <form class="form-horizontal" id="login" action="migration.py" method="post" name="">
-            <div class="form-group">
-                <div class="control-label col-sm-4">
-                    <label for="username">Username</label>
-                </div>
-                <div class="col-sm-8">
-                    <input type="text" id="username" name="username" value="" accesskey="u" class="form-control" />
-                </div>
-            </div>
-            <div class="form-group">
-                <div class="control-label col-sm-4">
-                    <label for="password">Password</label>
-                </div>
-                <div class="col-sm-8">
-                    <input type="password" id="password" name="password" value="" accesskey="p" class="form-control" />
-                </div>
-            </div>
-            <div class="form-group">
-                <div class="col-xs-4 col-sm-offset-4 col-sm-8 submit">
-                    <input name="submit" class="btn btn-primary btn-lg" value="Migrate" type="submit" />
-                </div>
-            </div>
-        </form>
-    </div>
-    <div class="col-sm-5 col-md-6 col-lg-7 details">
-        <h1>Password Migration</h1>
-        <p>
-            If you have been sent here by your administrator, your personal
-            information is being migrated to a new identity management solution
-            (IPA).
-        </p>
-        <p>
-            Please, enter your credentials in the form to complete the
-            process. Upon successful login your kerberos account will be
-            activated.
-        </p>
-    </div>
-</div>
-</div>
-</div>
+<body>
+	<noscript>This application requires JavaScript enabled.</noscript>
 </body>
 
 </html>
diff --git a/install/ui/src/freeipa/core.js b/install/ui/src/freeipa/core.js
index d906ec916b..4ac3f84ef2 100644
--- a/install/ui/src/freeipa/core.js
+++ b/install/ui/src/freeipa/core.js
@@ -21,7 +21,8 @@
 define([
     './app_container',
     './plugins/sync_otp',
-    './plugins/login'
+    './plugins/login',
+    './plugins/migrate'
 ],function(app_container) {
     return app_container;
-});
\ No newline at end of file
+});

From 622646675651bc4f74d8b8603002223f1fec9314 Mon Sep 17 00:00:00 2001
From: Stanislav Levin <s...@altlinux.org>
Date: Sat, 14 Jul 2018 14:25:16 +0300
Subject: [PATCH 5/8] Provide translatable messages for MigrateScreen widget

Translatable messages should be marked with @i18n. Also
these messages should be presented in "i18n_messages" dictionary.

Fixes: https://pagure.io/freeipa/issue/7641
---
 ipaserver/plugins/internal.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/ipaserver/plugins/internal.py b/ipaserver/plugins/internal.py
index 2bdd8fad18..e5c8f720a1 100644
--- a/ipaserver/plugins/internal.py
+++ b/ipaserver/plugins/internal.py
@@ -234,6 +234,7 @@ class i18n_messages(Command):
             "issue": _("Issue"),
             "match": _("Match"),
             "match_title": _("Match users according to certificate."),
+            "migrate": _("Migrate"),
             "ok": _("OK"),
             "refresh": _("Refresh"),
             "refresh_title": _("Reload current settings from the server."),
@@ -369,6 +370,24 @@ class i18n_messages(Command):
             "number_of_passwords": _("number of passwords"),
             "seconds": _("seconds"),
         },
+        "migration": {
+            "migrating": _("Migrating"),
+            "migration_error_msg": _(
+                "There was a problem with your request. Please, try again "
+                "later."),
+            "migration_failure_msg": _(
+                "Password migration was not successful"),
+            "migration_info_msg": _(
+                "<h1>Password Migration</h1><p>If you have been sent here by "
+                "your administrator, your personal information is being "
+                "migrated to a new identity management solution (IPA).</p><p>"
+                "Please, enter your credentials in the form to complete the "
+                "process. Upon successful login your kerberos account will be "
+                "activated.</p>"),
+            "migration_invalid_password": _(
+                "The password or username you entered is incorrect"),
+            "migration_success": _("Password migration was successful"),
+        },
         "objects": {
             "aci": {
                 "attribute": _("Attribute"),

From 31ad841e7401452c77c563d05403bf77474cd9aa Mon Sep 17 00:00:00 2001
From: Stanislav Levin <s...@altlinux.org>
Date: Sat, 14 Jul 2018 14:36:01 +0300
Subject: [PATCH 6/8] Clean up migration "error" and "invalid" pages from
 project

Migration error/invalid html pages are no longer needed as their
functionality was moved to "migrate" plugin.

Fixes: https://pagure.io/freeipa/issue/7641
---
 freeipa.spec.in                |  2 -
 install/migration/Makefile.am  |  2 -
 install/migration/error.html   | 40 ----------------
 install/migration/invalid.html | 83 ----------------------------------
 4 files changed, 127 deletions(-)
 delete mode 100644 install/migration/error.html
 delete mode 100644 install/migration/invalid.html

diff --git a/freeipa.spec.in b/freeipa.spec.in
index a01fae72c0..ef45ccee65 100644
--- a/freeipa.spec.in
+++ b/freeipa.spec.in
@@ -1415,9 +1415,7 @@ fi
 %{_usr}/share/ipa/html/ssbrowser.html
 %{_usr}/share/ipa/html/unauthorized.html
 %dir %{_usr}/share/ipa/migration
-%{_usr}/share/ipa/migration/error.html
 %{_usr}/share/ipa/migration/index.html
-%{_usr}/share/ipa/migration/invalid.html
 %{_usr}/share/ipa/migration/migration.py*
 %dir %{_usr}/share/ipa/ui
 %{_usr}/share/ipa/ui/index.html
diff --git a/install/migration/Makefile.am b/install/migration/Makefile.am
index 4d22de57cd..2c489ed023 100644
--- a/install/migration/Makefile.am
+++ b/install/migration/Makefile.am
@@ -2,9 +2,7 @@ NULL =
 
 appdir = $(IPA_DATA_DIR)/migration
 app_DATA =                              \
-	error.html			\
 	index.html			\
-	invalid.html			\
 	migration.py			\
 	$(NULL)
 
diff --git a/install/migration/error.html b/install/migration/error.html
deleted file mode 100644
index 896e56ec63..0000000000
--- a/install/migration/error.html
+++ /dev/null
@@ -1,40 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-    <title>IPA: Identity Policy Audit</title>
-
-    <link rel="stylesheet" type="text/css" href="../ui/css/patternfly.css" />
-    <link rel="stylesheet" type="text/css" href="../ui/css/ipa.css" />
-</head>
-
-<body class="info-page">
-    <nav class="navbar navbar-default navbar-pf" role="navigation">
-    <div class="navbar-header">
-        <a class="brand" href="../ui/index.html"><img src="../ui/images/header-logo.png" alt="FreeIPA"></a>
-    </div>
-    </nav>
-
-    <div class="container-fluid">
-    <div class="row">
-    <div class="col-sm-12">
-
-        <h1>We're Sorry</h1>
-        <div class="formcontent">
-            <p>
-                There was a problem with your request. Please, try again later.
-            </p>
-            <p>
-                If the problem persists, contact your administrator.
-            </p>
-            <p>
-                <a href="index.html" class="btn btn-default" title="Return back">Return back</a>
-            </p>
-       </div>
-    </div>
-    </div>
-    </div>
-</body>
-
-</html>
-
diff --git a/install/migration/invalid.html b/install/migration/invalid.html
deleted file mode 100644
index f75b0bdc7d..0000000000
--- a/install/migration/invalid.html
+++ /dev/null
@@ -1,83 +0,0 @@
-<!DOCTYPE html>
-<html class="login-pf">
-<head>
-<meta charset="utf-8">
-    <title>IPA: Identity Policy Audit</title>
-
-    <link rel="stylesheet" type="text/css" href="../ui/css/patternfly.css" />
-    <link rel="stylesheet" type="text/css" href="../ui/css/ipa.css" />
-    <link rel="stylesheet" type="text/css" href="../ui/ipa.css" />
-</head>
-
-<body>
-<div class="login-pf-body">
-<span id="badge">
-    <img src="../ui/images/login-screen-logo.png" alt="" />
-</span>
-<div class="container">
-
-<div class="row">
-
-    <div class="col-sm-12">
-      <div id="brand">
-        <img src="../ui/images/product-name.png" alt="">
-      </div>
-    </div>
-
-    <div class="col-sm-7 col-md-6 col-lg-5 login">
-        <form class="form-horizontal" id="login" action="migration.py" method="post" name="">
-            <div class="form-group validation-summary-group">
-                <div class="col-sm-12 controls">
-                    <div class="widget validation-summary">
-                        <div class="alert alert-danger">
-                            <span class="fa fa-exclamation-circle"></span>
-                            <p><strong>Please re-enter your username or password</strong></p>
-                            <p> The password or username you entered is incorrect. Please try
-                                again (make sure your caps lock is off).</p>
-                            <p>If the problem persists, contact your administrator.</p>
-                        </div>
-                    </div>
-                </div>
-            </div>
-            <div class="form-group">
-                <div class="control-label col-sm-4">
-                    <label for="username">Username</label>
-                </div>
-                <div class="col-sm-8">
-                    <input type="text" id="username" name="username" value="" accesskey="u" class="form-control" />
-                </div>
-            </div>
-            <div class="form-group">
-                <div class="control-label col-sm-4">
-                    <label for="password">Password</label>
-                </div>
-                <div class="col-sm-8">
-                    <input type="password" id="password" name="password" value="" accesskey="p" class="form-control" />
-                </div>
-            </div>
-            <div class="form-group">
-                <div class="col-xs-4 col-sm-offset-4 col-sm-8 submit">
-                    <input name="submit" class="btn btn-primary btn-lg" value="Migrate" type="submit" />
-                </div>
-            </div>
-        </form>
-    </div>
-    <div class="col-sm-5 col-md-6 col-lg-7 details">
-        <h1>Password Migration</h1>
-        <p>
-            If you have been sent here by your administrator, your personal
-            information is being migrated to a new identity management solution
-            (IPA).
-        </p>
-        <p>
-            Please, enter your credentials in the form to complete the
-            process. Upon successful login your kerberos account will be
-            activated.
-        </p>
-    </div>
-</div>
-</div>
-</div>
-</body>
-
-</html>

From aaa9412c0fabcc120116155b34bf56b14b5e0f00 Mon Sep 17 00:00:00 2001
From: Stanislav Levin <s...@altlinux.org>
Date: Tue, 17 Jul 2018 20:45:56 +0300
Subject: [PATCH 7/8] Add basic tests for "migration" end point

Fixes: https://pagure.io/freeipa/issue/7641
---
 ipatests/test_ipaserver/test_migratepw.py | 92 +++++++++++++++++++++++
 1 file changed, 92 insertions(+)
 create mode 100644 ipatests/test_ipaserver/test_migratepw.py

diff --git a/ipatests/test_ipaserver/test_migratepw.py b/ipatests/test_ipaserver/test_migratepw.py
new file mode 100644
index 0000000000..2a386389ee
--- /dev/null
+++ b/ipatests/test_ipaserver/test_migratepw.py
@@ -0,0 +1,92 @@
+#
+# Copyright (C) 2018  FreeIPA Contributors see COPYING for license
+#
+
+import pytest
+
+from ipatests.test_ipaserver.httptest import Unauthorized_HTTP_test
+from ipatests.test_xmlrpc.xmlrpc_test import XMLRPC_test
+from ipatests.util import assert_equal
+from ipalib import api, errors
+
+testuser = u'tuser'
+password = u'password'
+
+
+@pytest.mark.tier1
+class test_migratepw(XMLRPC_test, Unauthorized_HTTP_test):
+    """
+    Test password migrate end point
+    """
+    app_uri = '/ipa/migration/migration.py'
+
+    def setup(self):
+        """
+        Prepare for tests
+        """
+        api.Command['user_add'](uid=testuser, givenname=u'Test', sn=u'User')
+        api.Command['passwd'](testuser, password=password)
+
+    def teardown(self):
+        """
+        Clean up
+        """
+        try:
+            api.Command['user_del']([testuser])
+        except errors.NotFound:
+            pass
+
+    def _migratepw(self, user, password, method='POST'):
+        """
+        Make password migrate request to server
+        """
+        return self.send_request(method, params={'username': str(user),
+                                                 'password': str(password)},
+                                 )
+
+    def test_bad_params(self):
+        """
+        Test against bad (missing, empty) params
+        """
+        for params in (None,                     # no params
+                       {'username': 'foo'},       # missing password
+                       {'password': 'bar'},       # missing username
+                       {'username': '',
+                        'password': ''},         # empty options
+                       {'username': '',
+                        'password': 'bar'},      # empty username
+                       {'username': 'foo',
+                        'password': ''},         # empty password
+                       ):
+            response = self.send_request(params=params)
+            assert_equal(response.status, 400)
+            assert_equal(response.reason, 'Bad Request')
+
+    def test_not_post_method(self):
+        """
+        Test redirection of non POST request
+        """
+        response = self._migratepw(testuser, password, method='GET')
+
+        assert_equal(response.status, 302)
+        assert response.msg
+        assert_equal(response.msg['Location'], 'index.html')
+
+    def test_invalid_password(self):
+        """
+        Test invalid password
+        """
+        response = self._migratepw(testuser, 'wrongpassword')
+
+        assert_equal(response.status, 200)
+        assert_equal(response.getheader('X-IPA-Migrate-Result'),
+                     'invalid-password')
+
+    def test_migration_success(self):
+        """
+        Test successful migration scenario
+        """
+        response = self._migratepw(testuser, password)
+
+        assert_equal(response.status, 200)
+        assert_equal(response.getheader('X-IPA-Migrate-Result'), 'ok')

From 108e8caf8e370c4ff962157b23eb9c985a2cf57c Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Fri, 20 Jul 2018 18:28:25 +0200
Subject: [PATCH 8/8] webui: redable color of invalid fields on
 login-screen-like pages

Pages with widgets like LoginScreen, MigrateScreen use login-pf styling.
This page has dark background instead of light. Thus styling for labels
for fields with error has color which makes the label hard to read or
almost invisible.

Change it to white so it is still readable.

Fixes: https://pagure.io/freeipa/issue/7641
---
 install/ui/less/login.less | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/install/ui/less/login.less b/install/ui/less/login.less
index 281ad25680..8996560d33 100644
--- a/install/ui/less/login.less
+++ b/install/ui/less/login.less
@@ -29,6 +29,10 @@
     background: @login-bg-color url("@{img-path}/@{img-bg-login}") repeat-x 50% 0;
     background-size: auto;
     color: #fff;
+
+    .has-error .control-label {
+        color: #fff;
+    }
 }
 
 .reset-login-pf-height() {
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/freeipa-devel@lists.fedorahosted.org

Reply via email to