1 Replies - 1421 Views - Last Post: 04 April 2017 - 05:13 AM

#1 fearfulsc2   User is offline

  • D.I.C Regular

Reputation: 16
  • View blog
  • Posts: 272
  • Joined: 25-May 16

Unit Test a custom authorization API endpoint

Posted 03 April 2017 - 07:45 AM

Hey everyone, I am trying to figure out how to Unit Test an endpoint that is secure with a custom authentication I made.

How would I go about testing the controller in the API so that the CustomAuthorize attribute I created works?

I so far created an Interface for the CustomAuthorize class and then I mocked the Interface in the test class.

Do I have to mock the controller too?

And in the test class, how would I go about calling the endpoint so that the CustomAuthorize class and methods are invoked?

Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: Unit Test a custom authorization API endpoint

#2 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2906
  • View blog
  • Posts: 11,327
  • Joined: 03-December 12

Re: Unit Test a custom authorization API endpoint

Posted 04 April 2017 - 05:13 AM

Different kind of test. Unit testing test a specific piece of code under given circumstances, limiting dependency as much as possible.

Integration testing is used for completeness in testing.

Now, if you want to test the integration as a whole and how it operates, I user Postman. And here is a walk-thru of automated testing with it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1