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

Twitter API with socialite login test fails (Route Not Found Exception) #65

Open
osman-mohamad opened this issue May 13, 2017 · 2 comments

Comments

@osman-mohamad
Copy link

hi
I am writes feature tests with behat , mink and laravel . to auto authenticate laravel user with twitter api .
when I run the feature scenario . I get

NotFoundHttpException

this is my feature test

Feature: User Can Register And Login With Multiple Social Accounts
  In order to login easly and publish posts to social network
  As visitor
  I Want to register and login to the site with social account

  Social accounts:
    - Twitter
    - Facebook
    - google
    - linkedin
    - instagram
    - pinterest

  Scenario: Login And Register User With Twitter Successfully
    Given I am on homepage
    When I request login with twitter
    Then I should have associated social account with my username
    And I should be logged in to my time line page

and this the failing step definition

    /**
     * @When I request login with twitter
     */
    public function iRequestLoginWithTwitter()
    {
        $this->clickLink('twitter');
        $this->assertUrlRegExp('@/oauth/authenticate@');
        $this->showLastResponse();
        $this->assertElementContains('submit','Authorize app');
    }

next is the error page screen shot

screencapture-file

when I use the normal manual process it is opens the page . and I see the button 'Authorize app' button

can any one help me with this ?

@alnutile
Copy link
Contributor

are you sure those are GET related routes? Or POST?

I would assume either

  1. there is a setting that is switching between your .env and your .env.behat if you have that in place

  2. the routes are not using the Method you are expecting, with Behat this defaults to GET

??

@osman-mohamad
Copy link
Author

osman-mohamad commented May 14, 2017

are you sure those are GET related routes? Or POST?

yes I am sure


this is my behat settings

default:
  autoload: # contexts path
    '': %paths.base%/tests/Features/bootstrap
  extensions:
    tPayne\BehatMailExtension\ServiceContainer\MailExtension: ~
    Laracasts\Behat: ~
    Behat\MinkExtension:
      base_url: http://example.com
      show_cmd: google-chrome-stable %s
      browser_name: chrome
      javascript_session: selenium2
      default_session: laravel
      laravel: ~
      selenium2:
        browser: chrome
        wd_host: 'http://127.0.0.1:4444/wd/hub'

  suites:
    posts_features:
      paths: [%paths.base%/tests/Features/Posts] # suite feature paths
      contexts: [PostsContext] # suite feature contexts
    auth_features:
      paths: [%paths.base%/tests/Features/Auth] # suite feature paths
      contexts: [AuthContext] # suite feature contexts

and those are the related routes definitions

Route::get('/auth/login/{provider}', 'Auth\LoginController@socialLogin')
->name('auth.social-login');
Route::get('/auth/login/{provider}/handler', 'Auth\LoginController@socialProviderHandler')
->name('auth.social-login-handler');

and this is the route method i use to get user access token from twitter

   public function socialLogin($provider) {
        return Socialite::driver($provider)->redirect();
    }

I know it is not problem with my application . because it is working manually

by the way I used selenium as work around this . but it is not the best choice for testing some thing like this .


In your expert opinion when working with bdd and laravel . can you tell me better way to interact with other sites (like twitter) without use selenium ? just laravel , mink and behat ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants