Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Added guard to FormsAuthentication as per issue #1755 #1778

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Worthaboutapig
Copy link

Created guards on the four login/out methods.

Created tests for the changes- unfortunately all the FormsAuthentication stuff is static, so it can't really be tested properly. I've added an internal method for the test assembly to allow disabling FormsAuthentication so it can be tested. Not ideal, but with a static FormsAuthentication it's not really unit-testable.
Can't see another simple way to provide unit-testing, however, it introduces code only for testing, which is not great...

Believed I followed the correct procedures- read how to contribute, so I hope it's correctly setup.

…Enable' has been called.

Added tests- a bit hacky, as FormsAuthentication is static.
@@ -162,7 +161,71 @@ public void Should_return_ok_response_when_user_logs_in_without_redirect()
result.StatusCode.ShouldEqual(HttpStatusCode.OK);
}

[Fact]
#region Throw helpful exception when the configuration is not enabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use 4 spaces instead of tabs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ug. Yuck. Spaces. Ok. There isn't a style-guide, is there? There seems to be a space for one, but no link.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please get rid of the region? Thanks 😋

@Worthaboutapig
Copy link
Author

Errr... so what happens now? Can a committer have a look at this and decide how to resolve? Leave it as is, or accept it's not testable?

@albertjan
Copy link
Contributor

Leave it as it is for now. You can go to the chat and ask one of the commiters to have a look at it.

Sent from my iPhone

On 16 jan. 2015, at 18:18, "Worthaboutapig" [email protected] wrote:

Errr... so what happens now? Can a committer have a look at this and decide how to resolve? Leave it as is, or accept it's not testable?


Reply to this email directly or view it on GitHub.

@thecodejunkie thecodejunkie added this to the 1.3 milestone Aug 26, 2015
var result = Record.Exception(() => FormsAuthentication.UserLoggedInResponse(userGuid));

// Then
result.ShouldBeOfType(typeof(InvalidOperationException));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this to use the generic overload result.ShouldBeOfType<InvalidOperationException>();

@thecodejunkie
Copy link
Member

Need to convert tabs to spaces in all affected files + verify that the indentation is correct (currently it's not)

@@ -85,9 +85,9 @@
<DocumentationFile>bin\MonoRelease\Nancy.Testing.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="CsQuery, Version=1.3.3.5, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="CsQuery, Version=1.3.3.249, Culture=neutral, processorArchitecture=MSIL">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not change the version of our dependencies 😄

@thecodejunkie
Copy link
Member

This pull-request does seem to touch a lot of unrelated file for no good reason

  • Updating nuget versions
  • Changing reference paths
  • Razor View Engine related files
  • MaterialisingResponse
  • SharedAssemblyInfo

All of these things needs to be resolved if we are going to pull this in. @Worthaboutapig are you still interested in working with us to update this pull-request or would you rather we close it and apply a fix ourselves ? Looking at resolving #1755 very soon

@khellang khellang mentioned this pull request Aug 26, 2015
@Worthaboutapig
Copy link
Author

I'm happy to do the fix- tbh I thought it had been ignored. I've numerous other fixes/ suggestions.
I attempted to follow the rules, but clearly failed 😉. I'll fix it up as best I can and resubmit.

@thecodejunkie
Copy link
Member

@Worthaboutapig I do sincerely apologies that this was left hanging for so long without any feedback from us. We're trying to improve on that now and we've closed nearly 100 issues in 2 weeks :)

@thecodejunkie
Copy link
Member

The one thing that I do not like is the Disable method that's been added for testing purposes only. Let us give it some thought and see if we can come up with a better approach for that one

@Worthaboutapig
Copy link
Author

Clearly I can fix up all the unnecessary changes, but this last point you raise was the main reason I hadn't. FormsAuthentication and other similar plug-ins are all designed and configured statically. Due to this, I couldn't see any other way of testing it without the Disable method. Clearly it's not ideal, but once any test is run, there's no way to change anything... I'm not personally convinced that these things should be static in the first place.

Presumably you don't want to change that, but as I said originally, adding a Disable method was the least invasive way of making things testable... so either this, redesign FormsAuthentication to allow more testing, or don't have testing for this. :)

If someone has a better approach, that would be good.

I'm happy to fix up my code, but then until you have a design you're happy with, you won't merge it, so I also don't want to waste my time. What do you suggest?

@khellang
Copy link
Member

@Worthaboutapig All the config stuff is changing from static to instance based in 2.0. See #1999 and #2003.

@thecodejunkie
Copy link
Member

@khellang can you think of a decent workaround for the Disable call, or should we move this to 2.x ?

@Worthaboutapig
Copy link
Author

It would seem sensible to me to move it to 2.x, I can't think of a workaround and presumably the problem won't exist with an instance-based system and it's not a critical problem.

I'll take a look at implementing it into 2.x, if that's ok with you?

@jchannon jchannon modified the milestones: 1.4, 1.3 Sep 14, 2015
@thecodejunkie
Copy link
Member

Yep, we'll put this in 2.x and migrate it over to the new configuration API instread 👍

@thecodejunkie thecodejunkie modified the milestones: 2.0, 1.4 Sep 24, 2015
@thecodejunkie thecodejunkie self-assigned this Sep 24, 2015
@khellang khellang modified the milestones: 2.0, 2.0-beta Mar 22, 2016
@thecodejunkie thecodejunkie modified the milestones: 2.0-barneyrubble, 2.1 Jul 12, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants