Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lasley committed Jul 12, 2017
1 parent 0fe0499 commit b19837d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions oauth_provider/tests/common_test_controller.py
Expand Up @@ -149,14 +149,18 @@ def delete_request(
uri, data=data, environ_base=self.werkzeug_environ,
headers=headers, content_type=content_type)

def new_token(self):
return self.env['oauth.provider.token'].create({
def new_token(self, add_scopes=False):
vals = {
'token': 'token',
'token_type': 'Bearer',
'refresh_token': 'refresh token',
'client_id': self.client.id,
'scope_ids': [(6, 0, self.client.scope_ids.ids)],
'user_id': self.user.id,
'expires_at': fields.Datetime.to_string(
datetime.now() + timedelta(seconds=3600)),
})
}
if add_scopes:
vals.update({
'scope_ids': [(6, 0, self.client.scope_ids.ids)],
})
return self.env['oauth.provider.token'].create(vals)
Expand Up @@ -135,7 +135,7 @@ def test_refresh_token_error_too_much_scopes(self):
token = self.new_token()
response = self.post_request('/oauth2/token', data={
'client_id': self.client.identifier,
'scope': self.client.scope_ids.mapped('code'),
'scope': ' '.join(token.scope_ids.mapped('code')),
'grant_type': 'refresh_token',
'refresh_token': token.refresh_token,
})
Expand Down
2 changes: 1 addition & 1 deletion oauth_provider/tests/test_rest_api_controller.py
Expand Up @@ -15,7 +15,7 @@ def setUp(self):
super(TestRestApiController, self).setUp('legacy application')
self.logged_user = self.env.user
self.user = self.env.user
self.token = self.new_token().token
self.token = self.new_token(True).token
self.filter.domain = []
self.admin_user_data = {"city": self.user.city,
"login": self.user.login,
Expand Down

0 comments on commit b19837d

Please sign in to comment.