4
4
5
5
from grafana_api .model import APIModel
6
6
from grafana_api .service_account import ServiceAccount
7
- from grafana_api .authentication import Authentication
8
7
9
8
10
9
class ServiceAccountTest (TestCase ):
@@ -14,7 +13,6 @@ class ServiceAccountTest(TestCase):
14
13
http2_support = True if os .environ ["HTTP2" ] == "True" else False ,
15
14
)
16
15
service_account : ServiceAccount = ServiceAccount (grafana_api_model = model )
17
- authentication : Authentication = Authentication (grafana_api_model = model )
18
16
19
17
def test_lifecycle_service_account (self ):
20
18
service_account : dict = self .service_account .create_service_account (
@@ -64,36 +62,13 @@ def test_lifecycle_service_account(self):
64
62
service_account .get ("id" )
65
63
),
66
64
)
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 ())
70
65
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" ))
91
67
)
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" ))
92
70
93
71
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
- )
97
72
self .assertEqual (
98
73
1 , len (self .service_account .search_service_account ().get ("serviceAccounts" ))
99
74
)
0 commit comments