Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor inband registration (and cancelation) #559

Merged
merged 57 commits into from
Dec 1, 2015

Conversation

Dzol
Copy link
Contributor

@Dzol Dzol commented Oct 26, 2015

This began as a task to increase coverage, then became about making Mongoose conform to XEP 0077, but to do this we need to refactor.

@Dzol Dzol added the WIP 🚧 label Oct 26, 2015
@Dzol Dzol force-pushed the fix-inband-cancelation branch 3 times, most recently from 357c96c to 848cccf Compare November 3, 2015 10:47
@Dzol Dzol assigned Dzol and michalwski and unassigned Dzol Nov 4, 2015
@ppikula ppikula assigned ppikula and unassigned michalwski Nov 4, 2015
#xmlel{name = <<"password">>}
| QuerySubels]}]}
%% Clients must register before being able to authenticate.
process_unauthenticated_iq(Sender, Receiver, #iq{type = set} = Stanza, IPAddr) ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd stick to one standard - either use From/To or Sender/Receiver, not both alternately. The same story with IQ/Stanza. For me it was slightly misleading when I was comparing process_unauthenticated_iq to process_iq.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, changed both: commit 1d811e7.

@michalwski
Copy link
Contributor

One note from me. Maybe it's good time to move all test related to registration to a separate SUITE?

@Dzol
Copy link
Contributor Author

Dzol commented Nov 9, 2015

@michalwski Yeah, sure, I'll make the changes Paweł commented on. Then I'll move them over to their own suite.

error_response(IQ, ?ERR_FORBIDDEN)
end.

attempt_cancelation(ClientJID, #jid{lserver = ServerDomain}, #iq{id = ID, sub_el = Child} = IQ) ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cancelation -> cancellation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, the dictionary adds that US also cancelation :) My mistake.

@Dzol Dzol force-pushed the fix-inband-cancelation branch 2 times, most recently from 6d9df55 to 161d38b Compare November 23, 2015 10:37
process_iq_get(From, To, IQ, IPAddr).

process_iq(From, To, #iq{type = set} = IQ) ->
process_iq_set(From, To, IQ, jlib:jid_tolower(From));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look at jid module and change all the deprecated functions from jlib.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit 2f1765b fixes these.

@michalwski
Copy link
Contributor

How about try_set_password function. I think a test case for that should be easy.

@michalwski
Copy link
Contributor

Another test would be for the welcome message. This will require some mod_register config changes in init_per_testcase and reverting these changes in end_per_testcase.

Joseph Yiasemides added 21 commits November 30, 2015 15:33
Move necessary agruments out of the "extras".
That is: `Sender'/`Receiver' ---> `From'/`To', and `Stanza' ---> `IQ'.
Also rename the procedure that helps to switch on the children of the
"query" element and use more informative names for the atoms which are
returned.
When someone has authenticated, i.e. they are already registered,
Mongoose should respond with a `registered' IQ query element.
Matches will succeed when changing password: we were comparing the
sender of a stanza to a JID that hadn't been formatted according to
XMPP guidelines.
NOTE: This test fails until a fix to Mongoose is made.
Since the password change is an IQ request, even though XEP 0077 does
not describe this, we test for an error response.
The procedure in question had an empty string (i.e. "") as a pattern
in its head, but it's meant to be a binary (i.e. <<"">>), so add this
clause.
The calls made inside `*_per_testcase(null_password, _)' simply
shouldn't be necessary to test for an error response when a client
tries to register with an null password.
We were matching only on an empty string when we really need to match
on an empty binary.
Test for a <resource-constraint/> error-response after making inband
registration requests in quick succession NOT just that we receive an
error-response. The second paragraph of section 3.1.1 of XEP 0077 may
suggest using a <not-acceptable/>, see comment in test for more
detail.
Mongoose should restrict the number of registrations, regardles of a
client's recent success or failure, within a time period.
This makes it more clear that the timers are prerequisites for both
tests.
An "error" stanza will in fact produce a "failed_to_register", not a
"bad_response".
This concerns changes to the `{access, register, global}' variable,
used for inband registration.
Joseph Yiasemides added 3 commits December 1, 2015 12:41
Assert timeouts have expired before much of the registration process
begins: this'll make sure that registration requests are constrained
within a given time period, regardless of a client's recent
registration success or failure. It discriminates clients using their
IP address.
We use the Erlang binary internally.
michalwski added a commit that referenced this pull request Dec 1, 2015
Refactor inband registration (and cancelation)
@michalwski michalwski merged commit d1329cf into master Dec 1, 2015
@michalwski michalwski deleted the fix-inband-cancelation branch December 2, 2015 14:28
@michalwski michalwski mentioned this pull request Dec 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants