public void TestSuccessfulSpecificationInspector() { IAuthorizationContext context = MakeAuthorizationContext(); IContextInspector <IAuthorizationContext> inspector = new SpecificationInspector(); inspector.Inspect(context); }
public void TestNullClientContext() { TokenContext context = new TokenContext(); context.GrantType = Parameters.GrantTypeValues.AuthorizationCode; SpecificationInspector inspector = new SpecificationInspector(); inspector.Inspect(context); }
public void TestValidContext() { TokenContext context = new TokenContext(); context.GrantType = Parameters.GrantTypeValues.AuthorizationCode; context.Client = new ClientBase { ClientId = "123", ClientSecret = "secret" }; SpecificationInspector inspector = new SpecificationInspector(); inspector.Inspect(context); }
private static void CommonInvalidRequestSpecificationTest(IAuthorizationContext context, string parameter) { IContextInspector<IAuthorizationContext> inspector = new SpecificationInspector(); try { inspector.Inspect(context); Assert.Fail("No exception was thrown"); } catch (OAuthErrorResponseException<IAuthorizationContext> ex) { Assert.AreEqual(Parameters.ErrorParameters.ErrorValues.InvalidRequest, ex.Error); Assert.AreEqual("The '" + parameter + "' parameter is required and missing, unsupported, or malformed", ex.Message); } catch (Exception) { Assert.Fail("Threw an unexpected exception"); } }
private static void CommonInvalidRequestSpecificationTest(IAuthorizationContext context, string parameter) { IContextInspector <IAuthorizationContext> inspector = new SpecificationInspector(); try { inspector.Inspect(context); Assert.Fail("No exception was thrown"); } catch (OAuthErrorResponseException <IAuthorizationContext> ex) { Assert.AreEqual(Parameters.ErrorParameters.ErrorValues.InvalidRequest, ex.Error); Assert.AreEqual("The '" + parameter + "' parameter is required and missing, unsupported, or malformed", ex.Message); } catch (Exception) { Assert.Fail("Threw an unexpected exception"); } }
public void TestInvalidValidContext() { TokenContext context = new TokenContext(); context.GrantType = ""; SpecificationInspector inspector = new SpecificationInspector(); try { inspector.Inspect(context); Assert.Fail("Did not throw an exception"); } catch (OAuthErrorResponseException<ITokenContext> x) { Assert.AreEqual(Parameters.ErrorParameters.ErrorValues.InvalidRequest, x.Error); } catch (Exception) { Assert.Fail("Unexpected exception was thrown"); } }
public void TestInvalidValidContext() { TokenContext context = new TokenContext(); context.GrantType = ""; SpecificationInspector inspector = new SpecificationInspector(); try { inspector.Inspect(context); Assert.Fail("Did not throw an exception"); } catch (OAuthErrorResponseException <ITokenContext> x) { Assert.AreEqual(Parameters.ErrorParameters.ErrorValues.InvalidRequest, x.Error); } catch (Exception) { Assert.Fail("Unexpected exception was thrown"); } }
public void TestInvalidResponseTypeValue() { IAuthorizationContext context = MakeAuthorizationContext(); context.ResponseType = "unk"; IContextInspector <IAuthorizationContext> inspector = new SpecificationInspector(); try { inspector.Inspect(context); Assert.Fail("Did not throw exception"); } catch (OAuthErrorResponseException <IAuthorizationContext> ex) { Assert.AreEqual(Parameters.ErrorParameters.ErrorValues.UnsupportedResponseType, ex.Error); Assert.AreEqual("The 'unk' response type is unsupported", ex.Message); } catch (Exception) { Assert.Fail("Threw an unexpected excetpion"); } }
public void TestInvalidResponseTypeValue() { IAuthorizationContext context = MakeAuthorizationContext(); context.ResponseType = "unk"; IContextInspector<IAuthorizationContext> inspector = new SpecificationInspector(); try { inspector.Inspect(context); Assert.Fail("Did not throw exception"); } catch (OAuthErrorResponseException<IAuthorizationContext> ex) { Assert.AreEqual(Parameters.ErrorParameters.ErrorValues.UnsupportedResponseType, ex.Error); Assert.AreEqual("The 'unk' response type is unsupported", ex.Message); } catch (Exception) { Assert.Fail("Threw an unexpected excetpion"); } }
public void TestSuccessfulSpecificationInspector() { IAuthorizationContext context = MakeAuthorizationContext(); IContextInspector<IAuthorizationContext> inspector = new SpecificationInspector(); inspector.Inspect(context); }