From 722d0ceaa6b51bab7d5632dcf3923c82ebc6e634 Mon Sep 17 00:00:00 2001 From: Ethan Donowitz Date: Mon, 4 Oct 2021 20:50:35 +0000 Subject: [PATCH] minor changes; remove file --- tokenserver_rs.sql | 102 ------------------ .../tokenserver/test_authorization.py | 12 ++- .../tokenserver/test_node_assignment.py | 2 +- .../tokenserver/test_support.py | 2 +- 4 files changed, 9 insertions(+), 109 deletions(-) delete mode 100644 tokenserver_rs.sql diff --git a/tokenserver_rs.sql b/tokenserver_rs.sql deleted file mode 100644 index f48a726acf..0000000000 --- a/tokenserver_rs.sql +++ /dev/null @@ -1,102 +0,0 @@ --- MySQL dump 10.13 Distrib 8.0.26, for Linux (x86_64) --- --- Host: localhost Database: tokenserver_rs --- ------------------------------------------------------ --- Server version 8.0.26-0ubuntu0.20.04.2 - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!50503 SET NAMES utf8mb4 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `__diesel_schema_migrations` --- - -DROP TABLE IF EXISTS `__diesel_schema_migrations`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `__diesel_schema_migrations` ( - `version` varchar(50) NOT NULL, - `run_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`version`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `nodes` --- - -DROP TABLE IF EXISTS `nodes`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `nodes` ( - `id` bigint NOT NULL AUTO_INCREMENT, - `service` int NOT NULL, - `node` varchar(64) NOT NULL, - `available` int NOT NULL, - `current_load` int NOT NULL, - `capacity` int NOT NULL, - `downed` int NOT NULL, - `backoff` int NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `unique_idx` (`service`,`node`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `services` --- - -DROP TABLE IF EXISTS `services`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `services` ( - `id` int NOT NULL AUTO_INCREMENT, - `service` varchar(30) DEFAULT NULL, - `pattern` varchar(128) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `service` (`service`) -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `users` --- - -DROP TABLE IF EXISTS `users`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `users` ( - `uid` bigint NOT NULL AUTO_INCREMENT, - `service` int NOT NULL, - `email` varchar(255) NOT NULL, - `generation` bigint NOT NULL, - `client_state` varchar(32) NOT NULL, - `created_at` bigint NOT NULL, - `replaced_at` bigint DEFAULT NULL, - `nodeid` bigint NOT NULL, - `keys_changed_at` bigint DEFAULT NULL, - PRIMARY KEY (`uid`), - KEY `lookup_idx` (`email`,`service`,`created_at`), - KEY `replaced_at_idx` (`service`,`replaced_at`), - KEY `node_idx` (`nodeid`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb3; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2021-09-30 15:18:17 diff --git a/tools/integration_tests/tokenserver/test_authorization.py b/tools/integration_tests/tokenserver/test_authorization.py index 076d89a937..3e84b0872b 100644 --- a/tools/integration_tests/tokenserver/test_authorization.py +++ b/tools/integration_tests/tokenserver/test_authorization.py @@ -367,8 +367,10 @@ def test_kid_change_during_gradual_tokenserver_rollout(self): } # They sync again, but hit a tokenserver node that isn't updated yet. # This would trigger the allocation of a new user, so we simulate this - # by adding a new user. - uid = self._add_user(generation=2345, client_state='626262') + # by adding a new user. We set keys_changed_at to be the last-used + # value, since we are simulating a server that doesn't pay attention + # to keys_changed_at. + uid = self._add_user(generation=2345, keys_changed_at=1200, client_state='626262') user2 = self._get_user(uid) self.assertNotEqual(user1['uid'], user2['uid']) self.assertEqual(user1['nodeid'], user2['nodeid']) @@ -384,11 +386,11 @@ def test_kid_change_during_gradual_tokenserver_rollout(self): def test_update_client_state(self): uid = self._add_user(generation=0, keys_changed_at=None, - client_state='616161') + client_state='') user1 = self._get_user(uid) # The user starts out with no client_state self.assertEqual(user1['generation'], 0) - self.assertEqual(user1['client_state'], '616161') + self.assertEqual(user1['client_state'], '') seen_uids = set((uid,)) orig_node = user1['nodeid'] # Changing client_state allocates a new user, resulting in a new uid @@ -445,7 +447,7 @@ def test_update_client_state(self): oauth_token = self._forge_oauth_token(generation=1236) headers = { 'Authorization': 'Bearer %s' % oauth_token, - 'X-KeyID': '1236-YWFh' + 'X-KeyID': '1236-YmJi' } res = self.app.get('/1.0/sync/1.5', headers=headers, status=401) expected_error_response = { diff --git a/tools/integration_tests/tokenserver/test_node_assignment.py b/tools/integration_tests/tokenserver/test_node_assignment.py index 33dc42e374..f455ad68b5 100644 --- a/tools/integration_tests/tokenserver/test_node_assignment.py +++ b/tools/integration_tests/tokenserver/test_node_assignment.py @@ -66,7 +66,7 @@ def test_new_user_allocation(self): res = self.app.get('/1.0/sync/1.5', headers=headers) # The user should have been allocated to the least-loaded node # (computed as current_load / capacity) that has backoff and downed - # set to false + # set to 0 user = self._get_user(res.json['uid']) self.assertEqual(user['nodeid'], node_id) # The selected node should have current_load incremented and available diff --git a/tools/integration_tests/tokenserver/test_support.py b/tools/integration_tests/tokenserver/test_support.py index 9f88f7abc5..59de7f34d3 100644 --- a/tools/integration_tests/tokenserver/test_support.py +++ b/tools/integration_tests/tokenserver/test_support.py @@ -21,8 +21,8 @@ class TestCase: SYNC_1_1_SERVICE_ID = 1 SYNC_1_5_SERVICE_ID = 2 SYNC_1_5_SERVICE_NAME = 'sync-1.5' - TOKENSERVER_HOST = os.environ['TOKENSERVER_HOST'] TOKEN_SIGNING_SECRET = 'secret' + TOKENSERVER_HOST = os.environ['TOKENSERVER_HOST'] def setUp(self): self.database = mysql.connector.connect(