Module: Impostor::Wwf79::Auth

Defined in:
lib/impostor/wwf79.rb

Overview

Additional configuration parameters for a Wwf79 compatible agent:

:forum_posts_page :post_message_page

Typical configuration parameters { :type => :wwf79,

:app_root => 'http://example.com/forum/',
:login_page => 'login_user.asp',
:forum_posts_page => 'forum_posts.asp',
:post_message_page => 'post_message_form.asp'
:user_agent => 'Windows IE 7',
:username => 'myuser',
:password => 'mypasswd' }

Instance Method Summary collapse

Instance Method Details

#get_login_form(page) ⇒ Object

returns the login form from the login page



43
44
45
46
47
# File 'lib/impostor/wwf79.rb', line 43

def (page)
  form = page.form('frmLogin')
  raise Impostor::LoginError.new("unknown login page format") unless form
  form
end

#logged_in?(page) ⇒ Boolean

Checks if the agent is already logged by stored cookie

Returns:

  • (Boolean)


35
36
37
38
# File 'lib/impostor/wwf79.rb', line 35

def logged_in?(page)
  mm = page.search("//a[@class='nav']")
  !! mm.detect { |m| m.text =~ /Logout \[#{self.config.username}\]/ }
end

#loginObject

:nodoc:



27
28
29
30
# File 'lib/impostor/wwf79.rb', line 27

def  # :nodoc:
  Impostor.not_tested("Impostor::Wwf79::Auth", "login")
  super
end

#set_username_and_password(form) ⇒ Object

Sets the user name and pass word on the loing form.



51
52
53
54
55
56
57
# File 'lib/impostor/wwf79.rb', line 51

def set_username_and_password(form)
  button = Mechanize::Form::Button.new(form, 'Forum Login')
  form.add_button_to_query(button)
  form['name'] = self.config.username
  form['password'] = self.config.password
  form
end