jadahl / mod_restful

RESTful interface to ejabberd
84 stars 34 forks source link

probably a bug #27

Open Rom4eg opened 9 years ago

Rom4eg commented 9 years ago

I'm using ejabberd 15.04 and CentOS

config:

mod_restful:
    api:
      - path: ["admin"]
        module: mod_restful_admin
        params:
          key: "secret"
          allowed_commands: [register, unregister, change_password, get_vcard]
      - path: ["register"]
        module: mod_restful_register
        params:
          key: "secret"

POST request:

url:
    http://localhost:8088/api/admin

headers:
    CSP: active
    Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo
    User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36
    Content-Type: application/json 
    Accept: */*    
    DNT: 1
    Accept-Encoding: gzip, deflate
    Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4

body:
    {"args": ["some_login", "guest.example.ru", "FN"], "command": "get_vcard", "key": "secret"}

error:

[error] <0.795.0> Processing throwed error badarg
trace: [{erlang,list_to_binary,[<<"Test_Name">>],[]},{mod_restful_admin,format_result_json,2,[{file,"src/mod_restful_admin.erl"},{line,188}]},
{mod_restful_admin,format_result,3,[{file,"src/mod_restful_admin.erl"},{line,176}]},
{mod_restful_admin,do_process,1,[{file,"src/mod_restful_admin.erl"},{line,89}]},
{mod_restful,handle_rest_request,5,[{file,"src/mod_restful.erl"},{line,193}]},
{mod_restful,process,2,[{file,"src/mod_restful.erl"},{line,161}]},
{ejabberd_http,process,5,[{file,"src/ejabberd_http.erl"},{line,365}]},
{ejabberd_http,process_request,1,[{file,"src/ejabberd_http.erl"},{line,449}]}]

to reproduce the error:

  1. Change "Full Name" from xmpp client(i'm using pidgin)
  2. Send request

You've get BadRequest.

I'm test it in chrome extension "Advanced REST client", Python script, and wget (Linux utility) and I always get the same result(error in ejabberd.log).

"Test_Name" In first block it's a vcard "Full Name" - that I changed via pidgin before request.

Other similar requests like "register" "unregister, etc." work's fine, but those commands is a part of mod_admin module. Maybe it's because get_vcard is a part of mod_admin_extra and it's output has a different format?