Skip to content

Commit f4ce39c

Browse files
harshavardhanaminio-trusted
authored andcommitted
Fix broken tests with ENABLE_HTTPS=0
c798b8c broke our functional tests for non TLS server setups. This PR fixes this by skipping encryption tests on non-TLS servers. Fixes #691
1 parent c37b870 commit f4ce39c

File tree

1 file changed

+53
-41
lines changed

1 file changed

+53
-41
lines changed

tests/functional/tests.py

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def test_fput_object_with_content_type(client, testfile, log_output):
374374
def test_copy_object_no_copy_condition(client, log_output, ssec_copy=None, ssec=None):
375375
# default value for log_output.function attribute is;
376376
# log_output.function = "copy_object(bucket_name, object_name, object_source, conditions)"
377-
377+
378378
# Get a unique bucket_name and object_name
379379
log_output.args['bucket_name'] = bucket_name = generate_bucket_name()
380380
object_name = uuid.uuid4().__str__()
@@ -1661,8 +1661,10 @@ def test_remove_bucket(client, log_output):
16611661
# Test passes
16621662
print(log_output.json_report())
16631663

1664+
16641665
def isFullMode():
1665-
return os.getenv("MINT_MODE") == "full"
1666+
return os.getenv("MINT_MODE") == "full"
1667+
16661668

16671669
def main():
16681670
"""
@@ -1672,7 +1674,7 @@ def main():
16721674
try:
16731675
access_key = os.getenv('ACCESS_KEY', 'Q3AM3UQ867SPQQA43P2F')
16741676
secret_key = os.getenv('SECRET_KEY',
1675-
'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG')
1677+
'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG')
16761678
server_endpoint = os.getenv('SERVER_ENDPOINT', 'play.minio.io:9000')
16771679
secure = os.getenv('ENABLE_HTTPS', '1') == '1'
16781680
if server_endpoint == 'play.minio.io:9000':
@@ -1683,21 +1685,21 @@ def main():
16831685
client = Minio(server_endpoint, access_key, secret_key, secure=secure)
16841686
# Check if we are running in the mint environment.
16851687
data_dir = os.getenv('DATA_DIR')
1686-
if data_dir == None:
1688+
if data_dir is None:
16871689
os.environ['DATA_DIR'] = data_dir = '/mint/data'
16881690

1689-
is_mint_env = (os.path.exists(data_dir) and\
1690-
os.path.exists(os.path.join(data_dir, 'datafile-1-MB')) and\
1691-
os.path.exists(os.path.join(data_dir, 'datafile-11-MB')))
1691+
is_mint_env = (os.path.exists(data_dir) and
1692+
os.path.exists(os.path.join(data_dir, 'datafile-1-MB')) and
1693+
os.path.exists(os.path.join(data_dir, 'datafile-11-MB')))
16921694

16931695
# Enable trace
16941696
# import sys
16951697
# client.trace_on(sys.stderr)
16961698

16971699
testfile = 'datafile-1-MB'
16981700
largefile = 'datafile-11-MB'
1699-
if is_mint_env :
1700-
## Choose data files
1701+
if is_mint_env:
1702+
# Choose data files
17011703
testfile = os.path.join(data_dir, 'datafile-1-MB')
17021704
largefile = os.path.join(data_dir, 'datafile-11-MB')
17031705
else:
@@ -1712,7 +1714,6 @@ def main():
17121714
ssec = SSE_C(cust_key)
17131715
# Test copy_object for SSE-C
17141716
ssec_copy = copy_SSE_C(cust_key)
1715-
17161717

17171718
if isFullMode():
17181719
log_output = LogOutput(client.make_bucket, 'test_make_bucket_default_region')
@@ -1733,14 +1734,16 @@ def main():
17331734
log_output = LogOutput(client.fput_object, 'test_fput_object_small_file')
17341735
test_fput_object_small_file(client, testfile, log_output)
17351736

1736-
log_output = LogOutput(client.fput_object, 'test_fput_object_small_file_with_SSE-C')
1737-
test_fput_object_small_file(client, testfile, log_output, sse=ssec)
1737+
if secure:
1738+
log_output = LogOutput(client.fput_object, 'test_fput_object_small_file_with_SSE-C')
1739+
test_fput_object_small_file(client, testfile, log_output, sse=ssec)
17381740

17391741
log_output = LogOutput(client.fput_object, 'test_fput_object_large_file')
17401742
test_fput_object_large_file(client, largefile, log_output)
17411743

1742-
log_output = LogOutput(client.fput_object, 'test_fput_object_large_file_with_SSE-C')
1743-
test_fput_object_large_file(client, largefile, log_output, sse=ssec)
1744+
if secure:
1745+
log_output = LogOutput(client.fput_object, 'test_fput_object_large_file_with_SSE-C')
1746+
test_fput_object_large_file(client, largefile, log_output, sse=ssec)
17441747

17451748
log_output = LogOutput(client.fput_object, 'test_fput_object_with_content_type')
17461749
test_fput_object_with_content_type(client, testfile, log_output)
@@ -1760,44 +1763,50 @@ def main():
17601763
log_output = LogOutput(client.copy_object, 'test_copy_object_unmodified_since')
17611764
test_copy_object_unmodified_since(client, log_output)
17621765

1763-
log_output = LogOutput(client.copy_object, 'test_copy_object_with_sse')
1764-
test_copy_object_no_copy_condition(client, log_output, ssec_copy=ssec_copy, ssec=ssec)
1766+
if secure:
1767+
log_output = LogOutput(client.copy_object, 'test_copy_object_with_sse')
1768+
test_copy_object_no_copy_condition(client, log_output, ssec_copy=ssec_copy, ssec=ssec)
17651769

17661770
log_output = LogOutput(client.put_object, 'test_put_object')
17671771
test_put_object(client, log_output)
17681772

1769-
log_output = LogOutput(client.put_object, 'test_put_object_with_SSE-C')
1770-
test_put_object(client, log_output, sse=ssec)
1771-
1773+
if secure:
1774+
log_output = LogOutput(client.put_object, 'test_put_object_with_SSE-C')
1775+
test_put_object(client, log_output, sse=ssec)
1776+
17721777
log_output = LogOutput(client.put_object, 'test_negative_put_object_with_path_segment')
17731778
test_negative_put_object_with_path_segment(client, log_output)
17741779

17751780
log_output = LogOutput(client.stat_object, 'test_stat_object')
17761781
test_stat_object(client, log_output)
17771782

1778-
log_output = LogOutput(client.stat_object, 'test_stat_object_with_SSE-C')
1779-
test_stat_object(client, log_output, sse=ssec)
1783+
if secure:
1784+
log_output = LogOutput(client.stat_object, 'test_stat_object_with_SSE-C')
1785+
test_stat_object(client, log_output, sse=ssec)
17801786

17811787
log_output = LogOutput(client.get_object, 'test_get_object')
17821788
test_get_object(client, log_output)
17831789

1784-
log_output = LogOutput(client.get_object, 'test_get_object_with_SSE-C')
1785-
test_get_object(client, log_output,sse=ssec)
1790+
if secure:
1791+
log_output = LogOutput(client.get_object, 'test_get_object_with_SSE-C')
1792+
test_get_object(client, log_output, sse=ssec)
17861793

17871794
log_output = LogOutput(client.fget_object, 'test_fget_object')
17881795
test_fget_object(client, log_output)
17891796

1790-
log_output = LogOutput(client.fget_object, 'test_fget_object_with_SSE-C')
1791-
test_fget_object(client, log_output, sse=ssec)
1797+
if secure:
1798+
log_output = LogOutput(client.fget_object, 'test_fget_object_with_SSE-C')
1799+
test_fget_object(client, log_output, sse=ssec)
17921800

17931801
log_output = LogOutput(client.get_partial_object, 'test_get_partial_object_with_default_length')
17941802
test_get_partial_object_with_default_length(client, log_output)
17951803

17961804
log_output = LogOutput(client.get_partial_object, 'test_get_partial_object')
17971805
test_get_partial_object(client, log_output)
17981806

1799-
log_output = LogOutput(client.get_partial_object, 'test_get_partial_object_with_SSE-C')
1800-
test_get_partial_object(client, log_output)
1807+
if secure:
1808+
log_output = LogOutput(client.get_partial_object, 'test_get_partial_object_with_SSE-C')
1809+
test_get_partial_object(client, log_output)
18011810

18021811
log_output = LogOutput(client.list_objects, 'test_list_objects')
18031812
test_list_objects(client, log_output)
@@ -1836,7 +1845,7 @@ def main():
18361845
test_thread_safe(client, testfile, log_output)
18371846

18381847
log_output = LogOutput(client.get_bucket_policy, 'test_get_bucket_policy')
1839-
test_get_bucket_policy(client,log_output)
1848+
test_get_bucket_policy(client, log_output)
18401849

18411850
log_output = LogOutput(client.set_bucket_policy, 'test_set_bucket_policy_readonly')
18421851
test_set_bucket_policy_readonly(client, log_output)
@@ -1846,7 +1855,6 @@ def main():
18461855

18471856
else:
18481857
# Quick mode tests
1849-
18501858
log_output = LogOutput(client.make_bucket, 'test_make_bucket_default_region')
18511859
test_make_bucket_default_region(client, log_output)
18521860

@@ -1855,21 +1863,24 @@ def main():
18551863

18561864
log_output = LogOutput(client.put_object, 'test_put_object')
18571865
test_put_object(client, log_output)
1858-
1859-
log_output = LogOutput(client.put_object, 'test_put_object_with_SSE-C')
1860-
test_put_object(client, log_output, sse=ssec)
1861-
1866+
1867+
if secure:
1868+
log_output = LogOutput(client.put_object, 'test_put_object_with_SSE-C')
1869+
test_put_object(client, log_output, sse=ssec)
1870+
18621871
log_output = LogOutput(client.stat_object, 'test_stat_object')
18631872
test_stat_object(client, log_output)
18641873

1865-
log_output = LogOutput(client.stat_object, 'test_stat_object_with_SSE-C')
1866-
test_stat_object(client, log_output, sse=ssec)
1874+
if secure:
1875+
log_output = LogOutput(client.stat_object, 'test_stat_object_with_SSE-C')
1876+
test_stat_object(client, log_output, sse=ssec)
18671877

18681878
log_output = LogOutput(client.get_object, 'test_get_object')
18691879
test_get_object(client, log_output)
18701880

1871-
log_output = LogOutput(client.get_object, 'test_get_object_with_SSE-C')
1872-
test_get_object(client, log_output,sse=ssec)
1881+
if secure:
1882+
log_output = LogOutput(client.get_object, 'test_get_object_with_SSE-C')
1883+
test_get_object(client, log_output, sse=ssec)
18731884

18741885
log_output = LogOutput(client.list_objects, 'test_list_objects')
18751886
test_list_objects(client, log_output)
@@ -1889,11 +1900,12 @@ def main():
18891900
log_output = LogOutput(client.copy_object, 'test_copy_object_no_copy_condition')
18901901
test_copy_object_no_copy_condition(client, log_output)
18911902

1892-
log_output = LogOutput(client.copy_object, 'test_copy_object_with_sse')
1893-
test_copy_object_no_copy_condition(client, log_output, ssec_copy=ssec_copy, ssec=ssec)
1894-
1903+
if secure:
1904+
log_output = LogOutput(client.copy_object, 'test_copy_object_with_sse')
1905+
test_copy_object_no_copy_condition(client, log_output, ssec_copy=ssec_copy, ssec=ssec)
1906+
18951907
log_output = LogOutput(client.get_bucket_policy, 'test_get_bucket_policy')
1896-
test_get_bucket_policy(client,log_output)
1908+
test_get_bucket_policy(client, log_output)
18971909

18981910
log_output = LogOutput(client.set_bucket_policy, 'test_set_bucket_policy_readonly')
18991911
test_set_bucket_policy_readonly(client, log_output)

0 commit comments

Comments
 (0)