Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spar tests #539

Merged
merged 20 commits into from
Dec 7, 2018
Merged

Spar tests #539

merged 20 commits into from
Dec 7, 2018

Conversation

fisx
Copy link
Contributor

@fisx fisx commented Dec 4, 2018

  • stack test --fast --test-arguments=--quickcheck-replay=762030435
  • make spar log "listening on ..." on startup.
  • fix effectfulness of some tests re. deleting test idp. (look at Spec.hs for where this happens.)
  • test that SCIM and saml work together and SCIM-created users can login

@fisx fisx changed the title [WIP] spar tests Spar tests Dec 5, 2018
@fisx
Copy link
Contributor Author

fisx commented Dec 5, 2018

test that SCIM and saml work together and SCIM-created users can login

test is there, now we just need to make it pass... :-) @neongreen any comments what I'm doing wrong?

@fisx
Copy link
Contributor Author

fisx commented Dec 5, 2018

please review commit-by-commit.

@fisx
Copy link
Contributor Author

fisx commented Dec 6, 2018

(@neongreen you can review this already as is, but there is more coming up.)

@fisx
Copy link
Contributor Author

fisx commented Dec 6, 2018

Merged (and deleted) branch fisx-spar-tests-2 into fisx-spar-tests. I promise I'll stop touching this now until it's reviewed! :-)

@fisx
Copy link
Contributor Author

fisx commented Dec 6, 2018

Merged (and deleted) branch fisx-spar-tests-2 into fisx-spar-tests. I promise I'll stop touching this now until it's reviewed! :-)

I was lying. Pushed a 'Fixup' commit, now all spar tests pass at least locally. (Let's see if the CI is back.)

@@ -309,16 +308,15 @@ instance SCIM.UserDB Spar where
SCIM.serverError "The IdP corresponding to the provisioning token \
\was not found"
Just idpConfig -> pure (idpConfig ^. SAML.idpMetadata . SAML.edIssuer)
let uref = SAML.UserRef issuer (SAML.opaqueNameID extId)
let uref = traceShowId $ SAML.UserRef issuer (SAML.opaqueNameID extId)
Copy link
Contributor

Choose a reason for hiding this comment

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

Accidentally left here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. My process always was to remove the import Debug.Trace, and then let the compiler lead me to the places to wipe up. I guess that doesn't work any more unless I tweak Imports a little, and then you'll be sad. I'll try to adapt to Imports for a while I guess.

Copy link
Contributor

Choose a reason for hiding this comment

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

A solution I've seen in some other prelude is adding {-# DEPRECATED #-} to traceShow and friends so that it would compile but emit a warning. Would that be better for your workflow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, i like that idea. I'll make another PR at some point, thanks!

import Control.Lens
import Data.Id
import Data.String.Conversions
import Data.UUID as UUID
import Data.UUID.V4 as UUID
import Imports
Copy link
Contributor

Choose a reason for hiding this comment

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

Eh, it's at the beginning everywhere else (on purpose). I'm not against sorted imports everywhere, but I think inconsistencies are bad because they encourage sloppiness in general.

(And yeah, I'm rather guilty in this respect.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed this, but I am sloppy with imports because I think it's a waste of time to think about how they should be ordered. Looking forward to brittany!

liftIO $ userid'' `shouldBe` userid

-- /self should contain the expected UserSSOId
self :: ResponseLBS
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, don't we have this client function already written somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps, but it's harder to find than the write.

-- Get all users via SCIM
users <- listUsers Nothing
users <- listUsers tok Nothing
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps let's call it token? (Similarly to the push for "team" and so on instead of "tid")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

token is already in scope here. it's a local name, so i would prefer not to worry about it too much, but feel free to suggest something else.

@@ -35,6 +39,28 @@ import qualified Web.SCIM.Schema.Meta as SCIM
import qualified Web.SCIM.Schema.User as SCIM.User


registerIdPAndSCIMToken :: HasCallStack => TestSpar (ScimToken, (UserId, TeamId, IdP))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a haddock? Stating at least that a) the user is the owner of the created team and b) the token can be used to manipulate the team

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

(, team) <$> registerSCIMToken teamid (Just (idp ^. idpId))

registerSCIMToken :: HasCallStack => TeamId -> Maybe IdPId -> TestSpar ScimToken
registerSCIMToken teamid midpid = do
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be called more than once so let's add a random suffix or something to the token.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, thanks!

@fisx fisx requested a review from neongreen December 7, 2018 09:20
@fisx fisx merged commit e40bd8a into develop Dec 7, 2018
@fisx fisx deleted the fisx-spar-tests branch December 7, 2018 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants