<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Ramon,<br>
    <br>
    There is a problem with the patch I sent:<br>
    <tt><br>
    </tt><tt>diff --git a/src/wok/API.json b/src/wok/API.json</tt><tt><br>
    </tt><tt>index 3faa31b..4bbab55 100644</tt><tt><br>
    </tt><tt>--- a/src/wok/API.json</tt><tt><br>
    </tt><tt>+++ b/src/wok/API.json</tt><tt><br>
    </tt><tt>@@ -4,22 +4,26 @@</tt><tt><br>
    </tt><tt>     "description": "Json schema for Wok API",</tt><tt><br>
    </tt><tt>     "type": "object",</tt><tt><br>
    </tt><tt>     "properties": {</tt><tt><br>
    </tt><tt>-        "login": {</tt><tt><br>
    </tt><tt>+        "wokroot_login": {</tt><tt><br>
    </tt><tt>             "type": "object",</tt><tt><br>
    </tt><tt>             "properties": {</tt><tt><br>
    </tt><tt>                 "username": {</tt><tt><br>
    </tt><tt>                     "description": "Username",</tt><tt><br>
    </tt><tt>                     "required": true,</tt><tt><br>
    </tt><tt>                     "type": "string",</tt><tt><br>
    </tt><tt>+                    "minLength": 1,</tt><tt><br>
    </tt><tt>                     "error": "WOKAUTH0003E"</tt><tt><br>
    </tt><tt>                 },</tt><tt><br>
    </tt><tt>                 "password": {</tt><tt><br>
    </tt><tt>                     "description": "Password",</tt><tt><br>
    </tt><tt>                     "required": true,</tt><tt><br>
    </tt><tt>                     "type": "string",</tt><tt><br>
    </tt><tt>-                    "error": "WOKAUTH0003E"</tt><tt><br>
    </tt><tt>+                    "minLength": 1,</tt><tt><br>
    </tt><tt>+                    "error": "WOKAUTH0004E"</tt><tt><br>
    </tt><tt>                 }</tt><tt><br>
    </tt><tt>-            }</tt><tt><br>
    </tt><tt>+            },</tt><tt><br>
    </tt><tt>+            "additionalProperties": false,</tt><tt><br>
    </tt><tt>+            "error": "WOKAUTH0007E"</tt><tt><br>
    </tt><tt>         }</tt><tt><br>
    </tt><tt>     }</tt><tt><br>
    </tt><tt> }</tt><tt><br>
    </tt><tt>diff --git a/src/wok/i18n.py b/src/wok/i18n.py</tt><tt><br>
    </tt><tt>index 67b43ca..03a32ef 100644</tt><tt><br>
    </tt><tt>--- a/src/wok/i18n.py</tt><tt><br>
    </tt><tt>+++ b/src/wok/i18n.py</tt><tt><br>
    </tt><tt>@@ -40,10 +40,12 @@ messages = {</tt><tt><br>
    </tt><tt><br>
    </tt><tt>     "WOKAUTH0001E": _("Authentication failed for user
      '%(username)s'. [Error code: %(code)s]"),</tt><tt><br>
    </tt><tt>     "WOKAUTH0002E": _("You are not authorized to access
      Wok. Please, login first."),</tt><tt><br>
    </tt><tt>-    "WOKAUTH0003E": _("Specify %(item)s to login into
      Wok."),</tt><tt><br>
    </tt><tt>+    "WOKAUTH0003E": _("Specify username to login into
      Wok."),</tt><tt><br>
    </tt><tt>     "WOKAUTH0004E": _("You have failed to login in too
      much attempts. Please, wait for %(seconds)s seconds to try
      again."),</tt><tt><br>
    </tt><tt>     "WOKAUTH0005E": _("Invalid LDAP configuration:
      %(item)s : %(value)s"),</tt><tt><br>
    </tt><tt>     "WOKAUTH0006E": _("The username or password you
      entered is incorrect. Please try again."),</tt><tt><br>
    </tt><tt>+    "WOKAUTH0007E": _("You need to specify username and
      password to login into Wok."),</tt><tt><br>
    </tt><tt>+    "WOKAUTH0004E": _("Specify password to login into
      Wok."),</tt><br>
    <br>
    I have declared a WOKAUTH0004E which is already in use. So change it
    to WOKAUTH0008E and proper update API.json to reach that message.<br>
    <br>
    <div class="moz-cite-prefix">On 02/03/2017 11:58 AM, Aline Manera
      wrote:<br>
    </div>
    <blockquote
      cite="mid:8688d925-9bd1-15ef-00c4-2ced58303e0f@linux.vnet.ibm.com"
      type="cite">Hi Ramon,
      <br>
      <br>
      Please, check the attached patch. I did those changes on top of
      your patch and now the validation using JSON Schema is working as
      expected.
      <br>
      <br>
      Let me know if you have any doubts about the changes I did.
      <br>
      <br>
      Regards,
      <br>
      Aline Manera
      <br>
      <br>
      On 02/03/2017 11:13 AM, Ramon Medeiros wrote:
      <br>
      <blockquote type="cite">Just rebase it:
        <br>
        <br>
        <br>
        <br>
        On 2/3/17 11:06 AM, Aline Manera wrote:
        <br>
        <blockquote type="cite">
          <br>
          I am not able to apply the attached patch:
          <br>
          <br>
          [alinefm@alinefm-TP440 kimchi]$ git am -3
/home/alinefm/mail-patches/0001-Bug-fix-147-Block-authentication-request-after-too-m.patch<br>
          Applying: Bug fix #147: Block authentication request after too
          many failures
          <br>
          fatal: sha1 information is lacking or useless
          (src/wok/i18n.py).
          <br>
          error: could not build fake ancestor
          <br>
          Patch failed at 0001 Bug fix #147: Block authentication
          request after too many failures
          <br>
          The copy of the patch that failed is found in:
          /home/alinefm/wok/.git/modules/src/wok/plugins/kimchi/rebase-apply/patch
          <br>
          When you have resolved this problem, run "git am --continue".
          <br>
          If you prefer to skip this patch, run "git am --skip" instead.
          <br>
          To restore the original branch and stop patching, run "git am
          --abort".
          <br>
          <br>
          <br>
          On 02/01/2017 10:40 AM, Ramon Medeiros wrote:
          <br>
          <blockquote type="cite">Here is the patch
            <br>
            <br>
            <br>
            On 1/31/17 10:36 AM, Aline Manera wrote:
            <br>
            <blockquote type="cite">Hrm... Could you send the patch so I
              can do some debug?
              <br>
              <br>
              On 01/31/2017 10:32 AM, Ramon Medeiros wrote:
              <br>
              <blockquote type="cite">
                <br>
                <br>
                On 1/31/17 10:30 AM, Aline Manera wrote:
                <br>
                <blockquote type="cite">Hi Ramon,
                  <br>
                  <br>
                  Does the WokRoot class have set self.api_schema
                  attribute to get the right data?
                  <br>
                  <br>
                  It should have something like:
                  <br>
                  <br>
                  self.api_schema = json.load(&lt;path&gt;)
                  <br>
                  <br>
                  Regards,
                  <br>
                  Aline Manera
                  <br>
                </blockquote>
                <br>
                yes, it is:
                <br>
                <br>
                class WokRoot(Root):
                <br>
                    def __init__(self, model, dev_env=False):
                <br>
                        super(WokRoot, self).__init__(model, dev_env)
                <br>
                        self.default_page = 'wok-ui.html'
                <br>
                        for ident, node in sub_nodes.items():
                <br>
                            setattr(self, ident, node(model))
                <br>
                        with open(os.path.join(wok_paths.src_dir,
                'API.json')) as f:
                <br>
                            self.api_schema = json.load(f)
                <br>
                <blockquote type="cite">
                  <br>
                  On 01/30/2017 04:41 PM, Ramon Medeiros wrote:
                  <br>
                  <blockquote type="cite">
                    <br>
                    <br>
                    On 1/30/17 3:30 PM, Aline Manera wrote:
                    <br>
                    <blockquote type="cite">Hi Ramon,
                      <br>
                      <br>
                      There is a function in src/wok/control/utils.py
                      called model_fn() which determines the model
                      function name used by controller.
                      <br>
                      I think you need to use the same function in your
                      code and then update API.json accordingly.
                      <br>
                      <br>
                    </blockquote>
                    model_fn returned wokroot_login, which i already
                    tried. May i missing something on API.json?
                    <br>
                    <blockquote type="cite">On 01/27/2017 12:26 PM,
                      Ramon Medeiros wrote:
                      <br>
                      <blockquote type="cite">Just adding more
                        information:
                        <br>
                        <br>
                        at the pdb output, you can see "wokroot_login"
                        as method. I have already tried this one at
                        API.json
                        <br>
                        <br>
                        <br>
                        On 1/27/17 12:24 PM, Ramon Medeiros wrote:
                        <br>
                        <blockquote type="cite">Propose: valid strings
                          username and password with API.json
                          <br>
                          <br>
                          Issue: validator is not recognizing method
                          <br>
                          <br>
                          <br>
                          Just saw that src/wok/control/utils.py has a
                          method validate_params, that reads API and
                          validate the output of request_params. I've
                          added this changes to code:
                          <br>
                          <br>
                          diff --git a/src/wok/API.json
                          b/src/wok/API.json
                          <br>
                          index 8965db9..3faa31b 100644
                          <br>
                          --- a/src/wok/API.json
                          <br>
                          +++ b/src/wok/API.json
                          <br>
                          @@ -2,5 +2,24 @@
                          <br>
                               "$schema":
                          <a class="moz-txt-link-rfc2396E" href="http://json-schema.org/draft-03/schema#">"http://json-schema.org/draft-03/schema#"</a>,
                          <br>
                               "title": "Wok API",
                          <br>
                               "description": "Json schema for Wok API",
                          <br>
                          -    "type": "object"
                          <br>
                          +    "type": "object",
                          <br>
                          +    "properties": {
                          <br>
                          +        "login": {
                          <br>
                          +            "type": "object",
                          <br>
                          +            "properties": {
                          <br>
                          +                "username": {
                          <br>
                          +                    "description":
                          "Username",
                          <br>
                          +                    "required": true,
                          <br>
                          +                    "type": "string",
                          <br>
                          +                    "error": "WOKAUTH0003E"
                          <br>
                          +                },
                          <br>
                          +                "password": {
                          <br>
                          +                    "description":
                          "Password",
                          <br>
                          +                    "required": true,
                          <br>
                          +                    "type": "string",
                          <br>
                          +                    "error": "WOKAUTH0003E"
                          <br>
                          +                }
                          <br>
                          +            }
                          <br>
                          +        }
                          <br>
                          +    }
                          <br>
                           }
                          <br>
                          diff --git a/src/wok/root.py b/src/wok/root.py
                          <br>
                          index e4cecae..55e1886 100644
                          <br>
                          --- a/src/wok/root.py
                          <br>
                          +++ b/src/wok/root.py
                          <br>
                          @@ -32,7 +32,7 @@ from wok.i18n import
                          messages
                          <br>
                           from wok.config import paths as wok_paths
                          <br>
                           from wok.control import sub_nodes
                          <br>
                           from wok.control.base import Resource
                          <br>
                          -from wok.control.utils import parse_request
                          <br>
                          +from wok.control.utils import parse_request,
                          validate_params
                          <br>
                           from wok.exception import MissingParameter,
                          UnauthorizedError
                          <br>
                           from wok.reqlogger import log_request
                          <br>
                          <br>
                          @@ -170,6 +170,8 @@ class WokRoot(Root):
                          <br>
                          <br>
                                   try:
                          <br>
                                       params = parse_request()
                          <br>
                          +            validate_params(params, self,
                          "login")
                          <br>
                                       username = params['username']
                          <br>
                                       password = params['password']
                          <br>
                                   except KeyError, item:
                          <br>
                          <br>
                          <br>
                          Debugging the code, i just saw that the
                          action_name passed to validate_params (login)
                          is not found by the validator:
                          <br>
                          <br>
 /root/WOK/src/wok/control/utils.py(109)validate_params()
                          <br>
                          -&gt; validator.validate(request)
                          <br>
                          (Pdb) s
                          <br>
                          --Call--
                          <br>
                          &gt;
                          /usr/lib/python2.7/site-packages/jsonschema/validators.py(121)validate()
                          <br>
                          -&gt; def validate(self, *args, **kwargs):
                          <br>
                          (Pdb) n
                          <br>
                          &gt;
                          /usr/lib/python2.7/site-packages/jsonschema/validators.py(122)validate()
                          <br>
                          -&gt; for error in self.iter_errors(*args,
                          **kwargs):
                          <br>
                          (Pdb) s
                          <br>
                          --Call--
                          <br>
                          &gt;
/usr/lib/python2.7/site-packages/jsonschema/validators.py(78)iter_errors()<br>
                          -&gt; def iter_errors(self, instance,
                          _schema=None):
                          <br>
                          (Pdb) n
                          <br>
                          &gt;
/usr/lib/python2.7/site-packages/jsonschema/validators.py(79)iter_errors()<br>
                          -&gt; if _schema is None:
                          <br>
                          (Pdb)
                          <br>
                          &gt;
/usr/lib/python2.7/site-packages/jsonschema/validators.py(80)iter_errors()<br>
                          -&gt; _schema = self.schema
                          <br>
                          (Pdb)
                          <br>
                          &gt;
/usr/lib/python2.7/site-packages/jsonschema/validators.py(82)iter_errors()<br>
                          -&gt; scope = _schema.get(u"id")
                          <br>
                          (Pdb)
                          <br>
                          &gt;
/usr/lib/python2.7/site-packages/jsonschema/validators.py(83)iter_errors()<br>
                          -&gt; if scope:
                          <br>
                          (Pdb) print _schema
                          <br>
                          {u'$schema':
                          u'<a class="moz-txt-link-freetext" href="http://json-schema.org/draft-03/schema#">http://json-schema.org/draft-03/schema#</a>',
                          u'type': u'object', u'description': u'Json
                          schema for Wok API', u'properties':
                          {u'wokroot_login': {u'type': u'object',
                          u'properties': {u'username': {u'required':
                          True, u'type': u'string', u'description':
                          u'Username', u'error': u'WOKAUTH0003E'},
                          u'password': {u'required': True, u'type':
                          u'string', u'description': u'Password',
                          u'error': u'WOKAUTH0003E'}}}}, u'title': u'Wok
                          API'}
                          <br>
                          (Pdb) n
                          <br>
                          &gt;
/usr/lib/python2.7/site-packages/jsonschema/validators.py(85)iter_errors()<br>
                          -&gt; try:
                          <br>
                          (Pdb)
                          <br>
                          &gt;
/usr/lib/python2.7/site-packages/jsonschema/validators.py(86)iter_errors()<br>
                          -&gt; ref = _schema.get(u"$ref")
                          <br>
                          <br>
                          How i can know the correct one?
                          <br>
                          <br>
_______________________________________________
                          <br>
                          Kimchi-devel mailing list
                          <br>
                          <a class="moz-txt-link-abbreviated" href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a>
                          <br>
<a class="moz-txt-link-freetext" href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a>
                          <br>
                          <br>
                        </blockquote>
                        <br>
                        _______________________________________________
                        <br>
                        Kimchi-devel mailing list
                        <br>
                        <a class="moz-txt-link-abbreviated" href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a>
                        <br>
<a class="moz-txt-link-freetext" href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a>
                        <br>
                        <br>
                      </blockquote>
                      <br>
                    </blockquote>
                    <br>
                  </blockquote>
                  <br>
                </blockquote>
                <br>
              </blockquote>
              <br>
            </blockquote>
            <br>
          </blockquote>
          <br>
        </blockquote>
        <br>
      </blockquote>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Kimchi-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a>
<a class="moz-txt-link-freetext" href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>