Closed henri-hulski closed 8 years ago
Try App.lookup, though where in the test do you use it?
You cannot use autocommit in tests, just commit.
So it's okay to use morepath.commit()
without arguments?
App.lookup
doesn't work.
The test is:
def test_jwt_custom_settings():
morepath.scan(more.jwtauth)
class App(morepath.App):
pass
@App.setting_section(section="jwtauth")
def get_jwtauth_settings():
return {
'public_key': 'MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBWcJwPEAnS/k4kFgUhxNF7J0SQQhZG+nNgy+'
'/mXwhQ5PZIUmId1a1TjkNXiKzv6DpttBqduHbz/V0EtH+QfWy0B4BhZ5MnTyDGjcz1DQqKd'
'exebhzobbhSIZjpYd5aU48o9rXp/OnAnrajddpGsJ0bNf4rtMLBqFYJN6LOslAB7xTBRg=',
'algorithm': "ES256",
'leeway': 20
}
morepath.commit(App)
lookup = App().registry.lookup
assert settings(lookup=lookup).jwtauth.algorithm == "ES256"
assert settings(lookup=lookup).jwtauth.leeway == 20
assert settings(
lookup=lookup).jwtauth.public_key == 'MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBWcJwPEAnS/k4kFgUhxNF7J0SQQhZG+nNgy+' \
'/mXwhQ5PZIUmId1a1TjkNXiKzv6DpttBqduHbz/V0EtH+QfWy0B4BhZ5MnTyDGjcz1DQqKd' \
'exebhzobbhSIZjpYd5aU48o9rXp/OnAnrajddpGsJ0bNf4rtMLBqFYJN6LOslAB7xTBRg='
commit should get the App class as an argument. Sounds like the API docs need some improvements...
Try app.lookup, class instead of instance.
I think for the second test I actually don't need Morepath. I just can do
def test_encode_decode():
identity_policy = JWTIdentityPolicy(master_secret='secret')
claims_set = {
'sub': 'user'
}
token = identity_policy.encode_jwt(claims_set)
claims_set_decoded = identity_policy.decode_jwt(token)
assert claims_set_decoded == claims_set
Ah and the first one is lookup = App().lookup
.
So it seems to be fine now. Thanks.
No problem!
I put a few clarifications in the CHANGES for 0.13 so that at least people in the future can read it.
I have problems to get some tests to work.
does not work and I don't know, how to get that right.
This does work. If I use
morepath.commit()
it also works. But I'm not sure which one is right if any.@faassen Any ideas?