コード例 #1
0
    public void AuthenticationPasses()
    {
      var context = new OAuthContext { XAuthMode = "client_auth", XAuthUsername = "******", XAuthPassword = "******" };

      var inspector = new XAuthValidationInspector(ValidateXAuthMode, this.AuthenticateXAuthUsernameAndPassword);
      Assert.DoesNotThrow(() => inspector.InspectContext(ProviderPhase.CreateAccessToken, context));
    }
コード例 #2
0
    public void EmptyPasswordThrows()
    {
      var context = new OAuthContext { XAuthMode = "client_auth", XAuthUsername = "******" };

      var inspector = new XAuthValidationInspector(ValidateXAuthMode, this.AuthenticateXAuthUsernameAndPassword);
      var ex = Assert.Throws<OAuthException>(() => inspector.InspectContext(ProviderPhase.CreateAccessToken, context));
      Assert.Equal("The x_auth_password parameter must be present", ex.Message);
    }
コード例 #3
0
    public void AuthenticationFailureThrows()
    {
      var context = new OAuthContext { XAuthMode = "client_auth", XAuthUsername = "******", XAuthPassword = "******" };

      var inspector = new XAuthValidationInspector(ValidateXAuthMode, this.AuthenticateXAuthUsernameAndPassword);
      var ex = Assert.Throws<OAuthException>(() => inspector.InspectContext(ProviderPhase.CreateAccessToken, context));
      Assert.Equal("Authentication failed with the specified username and password", ex.Message);
    }
コード例 #4
0
    public void InvalidModeThrows()
    {
      var context = new OAuthContext { XAuthMode = "test_mode" };

      var inspector = new XAuthValidationInspector(ValidateXAuthMode, this.AuthenticateXAuthUsernameAndPassword);
      var ex = Assert.Throws<OAuthException>(() => inspector.InspectContext(ProviderPhase.CreateAccessToken, context));
      Assert.Equal("The x_auth_mode parameter is invalid", ex.Message);
    }