44from vaultwarden .clients .bitwarden import BitwardenAPIClient
55from vaultwarden .models .bitwarden import get_organization
66
7+ from .docker_helper import start_docker , stop_docker
8+
79# Get Bitwarden credentials from environment variables
810url = os .environ .get ("BITWARDEN_URL" , None )
911email = os .environ .get ("BITWARDEN_EMAIL" , None )
1012password = os .environ .get ("BITWARDEN_PASSWORD" , None )
1113client_id = os .environ .get ("BITWARDEN_CLIENT_ID" , None )
1214client_secret = os .environ .get ("BITWARDEN_CLIENT_SECRET" , None )
1315device_id = os .environ .get ("BITWARDEN_DEVICE_ID" , None )
14- bitwarden = BitwardenAPIClient (
15- url , email , password , client_id , client_secret , device_id
16- )
1716
1817# Get test organization id from environment variables
1918test_organization = os .environ .get ("BITWARDEN_TEST_ORGANIZATION" , None )
2019
2120
2221class BitwardenBasic (unittest .TestCase ):
22+ def tearDownClass () -> None :
23+ stop_docker ()
24+
2325 def setUp (self ) -> None :
24- self .organization = get_organization (bitwarden , test_organization )
26+ start_docker ()
27+ self .bitwarden = BitwardenAPIClient (
28+ url , email , password , client_id , client_secret , device_id
29+ )
30+ self .organization = get_organization (self .bitwarden , test_organization )
2531 self .test_colls_names = self .organization .collections (as_dict = True )
2632 self .test_colls_ids = self .organization .collections ()
2733 self .test_users = self .organization .users ()
@@ -39,6 +45,9 @@ def setUp(self) -> None:
3945 "test-collection-2"
4046 ).users ()
4147
48+ def tearDown (self ) -> None :
49+ stop_docker ()
50+
4251 def test_get_organization_users (self ):
4352 self .assertEqual (len (self .test_users ), 2 )
4453
0 commit comments