コード例 #1
0
  /**
   * After the test is finished, revoke the permission to the app so the login dialog appears again
   * on the next login when running the test See
   * https://developers.facebook.com/docs/facebook-login/permissions/v2.1#revokelogin
   */
  @After
  public void shutdown() {
    final FacebookAuthUser authUser =
        (FacebookAuthUser) (MyTestUserServicePlugin.getLastAuthUser());

    if (authUser == null) {
      // in case the test failed, we don't have an authUser
      return;
    }

    final String url = getConfig().getString("userInfoUrl") + "/permissions";
    WS.url(url)
        .setQueryParameter(
            OAuth2AuthProvider.Constants.ACCESS_TOKEN,
            authUser.getOAuth2AuthInfo().getAccessToken())
        .setQueryParameter("format", "json")
        .setQueryParameter("method", "delete")
        .get()
        .get(10, TimeUnit.SECONDS);
  }
コード例 #2
0
  @Test
  public void itShouldBePossibleToSignUp() throws InterruptedException {
    signupUser();

    // Make sure the redirect from localhost to fb happened already (and that {@link
    // MyUserServicePlugin#save()} gets called)
    Thread.sleep(3000);

    assertThat(browser.url()).isEqualTo("/#_=_");

    final FacebookAuthUser authUser =
        (FacebookAuthUser) (MyTestUserServicePlugin.getLastAuthUser());
    assertThat(authUser.getProfileLink()).contains(FACEBOOK_USER_ID);
    assertThat(authUser.getId()).isEqualTo(FACEBOOK_USER_ID);
    assertThat(authUser.getGender()).isEqualTo("female");

    final User user = User.findByEmail(FACEBOOK_USER_EMAIL);
    assertThat(user).isNotNull();
    assertThat(user.firstName).isEqualTo("Mary");
    assertThat(user.lastName).isEqualTo("Fallerman");
    assertThat(user.name).isEqualTo("Mary Ameafigjhhdb Fallerman");
  }