random_string utility function

7 views
Skip to first unread message

t.pickett66

unread,
Oct 1, 2012, 1:39:23 PM10/1/12
to rubycas...@googlegroups.com
I'm looking through the code and am confused by the spec that requires the random_string util function to include the character 'r'. I don't understand what the requirement is intended to accomplish, can someone explain it to me?

Matt Zukowski

unread,
Oct 1, 2012, 3:27:39 PM10/1/12
to rubycas...@googlegroups.com
To be honest I'm not entirely sure why  CASServer::Utils.random_string always starts with an "r". I suspect this is a vestige, and has something to do with the way that function evolved. If I had to guess, the random string part of the tickets generated by the original Java server always started with "r", so we copied that behaviour in the original ticket-generating code. The guy who wrote the Utils specs then ended up using this as a sanity check of some sort.

I'm not 100% sure, but I don't think anything would blow up if we stopped using "r" in those ticket strings, so it probably doesn't make sense to check for that in the spec.

As a reference for anyone else looking at this, the random_string code is here: https://github.com/rubycas/rubycas-server/blob/master/lib/casserver/utils.rb#L6-13. This function gets used all over the place in ticket generation (e.g. here: https://github.com/rubycas/rubycas-server/blob/master/lib/casserver/cas.rb#L15). The spec Tyler is asking about is here: https://github.com/rubycas/rubycas-server/blob/master/spec/utils_spec.rb#L27

On Mon, Oct 1, 2012 at 1:39 PM, t.pickett66 <ty...@therapylog.com> wrote:
I'm looking through the code and am confused by the spec that requires the random_string util function to include the character 'r'. I don't understand what the requirement is intended to accomplish, can someone explain it to me?

--
You received this message because you are subscribed to the Google Groups "RubyCAS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubycas-server/-/A-6k3M2Bc4UJ.
To post to this group, send email to rubycas...@googlegroups.com.
To unsubscribe from this group, send email to rubycas-serve...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubycas-server?hl=en.

t.pickett66

unread,
Oct 1, 2012, 3:30:50 PM10/1/12
to rubycas...@googlegroups.com, ma...@roughest.net
Good to know, thanks!
Reply all
Reply to author
Forward
0 new messages