public void RegularKey() { //Regular key var headers = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("apiKey", Properties.Settings.Default.apiKey) }; InitializeContext(headers, false); var attr = new OnlyAuthorizedAttribute(); attr.OnAuthorization(actionContext); Assert.IsNull(actionContext.Response); }
public void Anonymous() { //Regular key var headers = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("apiKey", "XXX") }; InitializeContext(headers, true); var attr = new OnlyAuthorizedAttribute(); attr.OnAuthorization(actionContext); Assert.IsNull(actionContext.Response); }
public void FakeKey() { //First fake key var headers = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("apiKey", "XXX") }; InitializeContext(headers, false); var attr = new OnlyAuthorizedAttribute(); attr.OnAuthorization(actionContext); Assert.AreEqual(HttpStatusCode.Unauthorized, actionContext.Response.StatusCode); }