44
55from grafana_api .model import APIModel
66from grafana_api .service_account import ServiceAccount
7- from grafana_api .authentication import Authentication
87
98
109class ServiceAccountTest (TestCase ):
@@ -14,7 +13,6 @@ class ServiceAccountTest(TestCase):
1413 http2_support = True if os .environ ["HTTP2" ] == "True" else False ,
1514 )
1615 service_account : ServiceAccount = ServiceAccount (grafana_api_model = model )
17- authentication : Authentication = Authentication (grafana_api_model = model )
1816
1917 def test_lifecycle_service_account (self ):
2018 service_account : dict = self .service_account .create_service_account (
@@ -64,36 +62,13 @@ def test_lifecycle_service_account(self):
6462 service_account .get ("id" )
6563 ),
6664 )
67- self .authentication .create_api_token ("Test-all-migrated" , "Viewer" )
68- self .service_account .migrate_api_keys_to_service_accounts ()
69- self .assertEqual (list (), self .authentication .get_api_tokens ())
7065 self .assertEqual (
71- 3 , len (self .service_account .search_service_account ().get ("serviceAccounts" ))
72- )
73- service_account_all_migrated : dict = (
74- self .service_account .search_service_account (query = "Test-all-migrated" )
75- )
76- self .service_account .delete_service_account (
77- service_account_all_migrated .get ("serviceAccounts" )[0 ].get ("id" )
78- )
79-
80- token : dict = self .authentication .create_api_token ("Test-migrated" , "Viewer" )
81- self .service_account .migrate_api_key_to_service_account (token .get ("id" ))
82- self .assertEqual (
83- 3 , len (self .service_account .search_service_account ().get ("serviceAccounts" ))
84- )
85- service_account_migrated : dict = self .service_account .search_service_account (
86- query = "Test-migrated"
87- )
88-
89- self .assertEqual (
90- 3 , len (self .service_account .search_service_account ().get ("serviceAccounts" ))
66+ 2 , len (self .service_account .search_service_account ().get ("serviceAccounts" ))
9167 )
68+ self .service_account .create_service_account_token_by_id (service_account .get ("id" ), "Test" , "Viewer" )
69+ self .assertEqual (1 , self .service_account .search_service_account ().get ("serviceAccounts" )[0 ].get ("tokens" ))
9270
9371 self .service_account .delete_service_account (service_account .get ("id" ))
94- self .service_account .delete_service_account (
95- service_account_migrated .get ("serviceAccounts" )[0 ].get ("id" )
96- )
9772 self .assertEqual (
9873 1 , len (self .service_account .search_service_account ().get ("serviceAccounts" ))
9974 )
0 commit comments