5
5
6
6
import os
7
7
import tempfile
8
+ import pytest
9
+ import oci
8
10
9
11
from mock import patch
10
12
@@ -15,34 +17,35 @@ class TestCoreSite:
15
17
@patch ("oci.signer.load_private_key_from_file" )
16
18
@patch ("oci.config.invalid_key_file_path_checker" )
17
19
def test_generate_core_site_with_api_key (self , mock_checker , mock_load_key ):
18
- with tempfile .TemporaryDirectory () as td :
19
- with open (os .path .join (td , "config.ini" ), "w" ) as f :
20
- f .write (
20
+ with pytest .raises (oci .exceptions .InvalidConfig ):
21
+ with tempfile .TemporaryDirectory () as td :
22
+ with open (os .path .join (td , "config.ini" ), "w" ) as f :
23
+ f .write (
24
+ """
25
+ [PROFILE_NAME]
26
+ user = ocid1.user.oc1.xxxxx
27
+ fingerprint = 79:42:80:31:52:12:34
28
+ tenancy = ocid1.tenancy.oc1.xxxx
29
+ region = us-ashburn-1
30
+ key_file = ~/.oci/oci_api_key.pem
21
31
"""
22
- [PROFILE_NAME]
23
- user = ocid1.user.oc1.xxxxx
24
- fingerprint = 79:42:80:31:52:12:34
25
- tenancy = ocid1.tenancy.oc1.xxxx
26
- region = us-ashburn-1
27
- key_file = ~/.oci/oci_api_key.pem
28
- """
32
+ )
33
+ properties = generate_core_site_properties (
34
+ "api_key" , os .path .join (td , "config.ini" ), "PROFILE_NAME"
29
35
)
30
- properties = generate_core_site_properties (
31
- "api_key" , os .path .join (td , "config.ini" ), "PROFILE_NAME"
32
- )
33
- assert properties == [
34
- (
35
- "fs.oci.client.hostname" ,
36
- f"https://objectstorage.us-ashburn-1.oraclecloud.com" ,
37
- ),
38
- ("fs.oci.client.auth.tenantId" , "ocid1.tenancy.oc1.xxxx" ),
39
- ("fs.oci.client.auth.userId" , "ocid1.user.oc1.xxxxx" ),
40
- ("fs.oci.client.auth.fingerprint" , "79:42:80:31:52:12:34" ),
41
- (
42
- "fs.oci.client.auth.pemfilepath" ,
43
- os .path .expanduser ("~/.oci/oci_api_key.pem" ),
44
- ),
45
- ]
36
+ assert properties == [
37
+ (
38
+ "fs.oci.client.hostname" ,
39
+ f"https://objectstorage.us-ashburn-1.oraclecloud.com" ,
40
+ ),
41
+ ("fs.oci.client.auth.tenantId" , "ocid1.tenancy.oc1.xxxx" ),
42
+ ("fs.oci.client.auth.userId" , "ocid1.user.oc1.xxxxx" ),
43
+ ("fs.oci.client.auth.fingerprint" , "79:42:80:31:52:12:34" ),
44
+ (
45
+ "fs.oci.client.auth.pemfilepath" ,
46
+ os .path .expanduser ("~/.oci/oci_api_key.pem" ),
47
+ ),
48
+ ]
46
49
47
50
def test_generate_core_site_with_rp (self , monkeypatch ):
48
51
monkeypatch .setenv ("NB_REGION" , "us-ashburn-1" )
0 commit comments