Exemplo n.º 1
0
	def test_create_random(self):
		result = oauth2.create_client()
		data = json.loads(result)
		client_id = data['client_id']
		client_secret = data['client_secret']

		code = self.get_code(client_id)

		token_request = {'client_id':client_id, 'client_secret':client_secret,
		                 'grant_type':'authorization_code', 'code':code}
		resp = oauth2.token(token_request)
		token_data = json.loads(resp)
		assert_in('access_token', token_data)
		assert_in('expires_in', token_data)
		assert_in('token_type', token_data)
		assert_not_in('refresh_token', token_data)
		# throws an exception if invalid
		works = oauth2.validate_access_token(token_data['access_token'])

		# auth_token should not be valid a second time
		try:
			resp = oauth2.token(token_request)
			fail()
		except:
			pass
Exemplo n.º 2
0
	def test_create(self):
		result = oauth2.create_client()
		data = json.loads(result)
		assert_in('client_id', data)
		assert_in('client_secret', data)
		client_id = data['client_id']
		client_secret = data['client_secret']
		assert_true(len(client_id) > 5, "id too short: %s"%(client_id,))
		assert_true(len(client_secret) > 10, "secret too short: %s"%(client_secret,))
		assert_in(client_id, oauth2.clients)
		assert_equal(oauth2.clients[client_id], client_secret)