o_auth_controller_test.rb 1.1 KB

1234567891011121314151617181920212223242526272829
  1. require 'test_helper'
  2. class OAuthControllerTest < ActionDispatch::IntegrationTest
  3. test 'o365 - start' do
  4. get '/auth/microsoft_office365', params: {}
  5. assert_response(302)
  6. assert_match('https://login.microsoftonline.com/common/oauth2/v2.0/authorize', @response.body)
  7. assert_match('redirect_uri=http%3A%2F%2Fzammad.example.com%2Fauth%2Fmicrosoft_office365%2Fcallback', @response.body)
  8. assert_match('scope=openid+email+profile', @response.body)
  9. assert_match('response_type=code', @response.body)
  10. end
  11. test 'o365 - callback' do
  12. get '/auth/microsoft_office365/callback?code=1234&state=1234', params: {}
  13. assert_response(302)
  14. assert_match('302 Moved', @response.body)
  15. end
  16. test 'auth failure' do
  17. get '/auth/failure?message=123&strategy=some_provider', params: {}
  18. assert_response(422)
  19. assert_match('<title>422: Unprocessable Entity</title>', @response.body)
  20. assert_match('<h1>422: The change you wanted was rejected.</h1>', @response.body)
  21. assert_match('<div>Message from some_provider: 123</div>', @response.body)
  22. end
  23. end