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

eID-Service Integration #57

Merged
merged 3 commits into from
Aug 30, 2017
Merged

eID-Service Integration #57

merged 3 commits into from
Aug 30, 2017

Conversation

BenjaminKeller
Copy link
Collaborator

@BenjaminKeller BenjaminKeller commented Aug 22, 2017

This pull request implements the required functionality of the interfaces of the eID-Service.

It contains the interface to the eID-Server so the SAML-procedure has only to modify the value of restrictedId in the ServiceRequest table. @Armagetron Please give some feedback about that.

Moreover it provides the view getUserId for the openId Provider. The refreshAddress provides a json containing the access token:

{"accessToken": "9465901b-6693-462b-9044-db3a80fe0cd0"}

getUserId provides the restricted id as base64:

{"userId": "b''"}

@nielsgroth @m273d15 @larissazech Please give some feedback.

See also #44 and #46.

Copy link
Collaborator

@nils-wisiol nils-wisiol left a comment

Choose a reason for hiding this comment

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

As a general point, please increase code documentation throughout your PR.

});
});

it("is working fine", function(done) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The description here should be a little more descriptive. I advise to split this test case into several expectation handlers to make it more readable:

frisby.get(....getTcTokenUrl....)
  .expect('status', 302)
  .expect('tcToken retrievable')

where the new tcToken retrievable expectation handlers implements most of the actual testing.

With #55 in mind, this should be compatible with chakram by extending chai.

@@ -0,0 +1,39 @@
describe("eID-Service: The general flow", function() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This suit just contains one positive test case. Please also add some negative checks to increase the test coverage to the cases where we need to reply faulty requests in the eid service / eid server.

@nils-wisiol
Copy link
Collaborator

nils-wisiol commented Aug 22, 2017

It may be worthwhile to add a README to the eid server Django app to summarize the interface. Alternatively, this could be entirely put in code docs.

@BenjaminKeller
Copy link
Collaborator Author

BenjaminKeller commented Aug 22, 2017

You're right. Doc is now required as the complexity is high. I put it in code.

Update: I added documentation.

TODO:

@auvin
Copy link
Collaborator

auvin commented Aug 22, 2017

Currently the openid provider expects a POST with username, client_id, redirect_uri, response_type, scope and state. The username is used to present the restricted userID, so i think we can than use the provided getUserId for that.
The other attributes are present as soon as the user clicks 'login with eid' and should be forwarded from that point on.

@larissazech, @m273d15 Please correct me, if i am wrong.

Edit: See #62 for a description more precisely.

@BenjaminKeller BenjaminKeller force-pushed the eidservice_integration branch 5 times, most recently from 969518c to 2954bfb Compare August 28, 2017 15:31
@BenjaminKeller
Copy link
Collaborator Author

BenjaminKeller commented Aug 28, 2017

Chakram seems to be broken, too?
@nils-wisiol Done.

@nils-wisiol
Copy link
Collaborator

nils-wisiol commented Aug 29, 2017

@BenjaminKeller

Chakram seems to be broken, too?

looks good to me, why do you think it is broken?

@BenjaminKeller
Copy link
Collaborator Author

BenjaminKeller commented Aug 29, 2017

@nils-wisiol The link is not working. Have a look at build #266 in travis. the tc token generator returns a tc token is the only test that fails but it affects 6 other tests, too.

Rebasing done.

@nils-wisiol
Copy link
Collaborator

In the travis build, tests fail as regex do not match. The Location that was sent,

https://eid.local/api/openid/login?eid_access_token=5cd623f4-9cd4-46a4-b49c-ea330fe8fb11&test=bla&foo=bar

does indeed not match the given expression

/\/api\/openid\/login?eid_access_token=.*[&]test=bla[&]foo=bar$/

Try escaping ? and _:

/\/api\/openid\/login\?eid\_access\_token=.*[&]test=bla[&]foo=bar$/

Also useful.

@BenjaminKeller
Copy link
Collaborator Author

Hi @nils-wisiol your described issue was problem of the test The refresh page redirects correctly with GET parameters. And obviously it is now working and I have fixed that a day ago. The other tests (eID-Service: The tcTokenUrl generator redirects by default and so on) are in a completely different file with a completely different definition. The regex in this file is also completely different from the displayed. And they fail because the the other test fails. That's the problem.

Nevertheless, this branch can be merged.

@nils-wisiol
Copy link
Collaborator

I'd blame that problem on the double-definition (here and here) of the correctRedirect property.

Chakram (using chai) runs all tests parallel, so you get a race condition and your expectation was overwritten.

I didn't reproduce this locally, but unless there is indication that this theory could be wrong, I'd rather spare the work.

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
Copy link
Collaborator

Choose a reason for hiding this comment

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

@@ -0,0 +1,24 @@
from eid_server.models import ServiceRequest
Copy link
Collaborator

Choose a reason for hiding this comment

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

according to PEP8, python modules (i.e. source files) should have all lower-case names

@BenjaminKeller
Copy link
Collaborator Author

BenjaminKeller commented Aug 29, 2017

This shouldn't be a problem as every suite has its own before call.

Do you have any further suggestions or can we merge?

@nils-wisiol
Copy link
Collaborator

nils-wisiol commented Aug 29, 2017

The double definition is put onto a singleton object, that's why the old one is overwritten. (That's how require.js works)

@BenjaminKeller BenjaminKeller force-pushed the eidservice_integration branch 3 times, most recently from 1f00fe5 to bd4f61b Compare August 29, 2017 14:10
@BenjaminKeller
Copy link
Collaborator Author

@nils-wisiol Files renamed, database migrated and tests improved. Do you check line feeds, formatting and style conventions manually or do you have some cool tool?

Copy link
Collaborator

@nils-wisiol nils-wisiol left a comment

Choose a reason for hiding this comment

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

This lgtm! Nice work.

I found one more typo, see code annotations. One more general thing, using 'correct' as test description is a tautology: your tests always check if the system behaves correctly. So, if you want to further improve this PR, rename the tests to something avoiding the word 'correct'. How about adding a method rather than a property that can be used like expect(...).to.redirect_to(CONST_REGEX)? Anyways, this is good enough for merging (but please fix the typo real quick -- the approval will stay).


def error(request):
return HttpResponse("An error occurred during the authentication.")
"""
The use agent is redirected to this view if the authentication session between eID-Client
Copy link
Collaborator

Choose a reason for hiding this comment

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

"user agent"

@nils-wisiol
Copy link
Collaborator

I do not use a tool to check style conventions on reviews (unless I have a suspicion), but I recommend pycharm's integrated style checker. For line endings, I find GNU/Linux' file command helpful. I used it for checking line endings in a bunch of files at once.

@BenjaminKeller
Copy link
Collaborator Author

@nils-wisiol Thank you very much for your answer. I fixed the typo. I will use a constant redirect test function for testing next time!

@nils-wisiol
Copy link
Collaborator

nils-wisiol commented Aug 29, 2017 via email

@larissazech larissazech merged commit 4278974 into master Aug 30, 2017
@BenjaminKeller BenjaminKeller deleted the eidservice_integration branch August 31, 2017 19:29
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.

4 participants