File tree Expand file tree Collapse file tree 8 files changed +92
-3
lines changed
Expand file tree Collapse file tree 8 files changed +92
-3
lines changed Original file line number Diff line number Diff line change 1+ # Lines starting with '#' are comments.
2+ # Each line is a file pattern followed by one or more owners.
3+
4+ # These owners will be the default owners for everything in the repo.
5+ * @ anu3990 @ billfarber @ rjrudin
Original file line number Diff line number Diff line change @@ -17,3 +17,11 @@ To run the tests:
1717- Run ` ./gradlew -i mlDeploy `
1818- ` cd .. `
1919- Run ` pytest `
20+
21+ To run an individual test with logging to stdout:
22+
23+ pytest -s tests/test_search.py
24+
25+ To run an individual test method:
26+
27+ pytest -s test/test_search.py::test_search
Original file line number Diff line number Diff line change 11plugins {
22 id ' net.saliman.properties' version ' 1.5.2'
33 id ' com.marklogic.ml-gradle' version ' 4.5.2'
4- }
4+ }
5+
6+ // Generate a temporary certificate for some simple SSL tests
7+ ext {
8+ def command = new com.marklogic.appdeployer.command.security.GenerateTemporaryCertificateCommand ()
9+ command. setTemplateIdOrName(" python-test-ssl-template" )
10+ command. setCommonName(" localhost" )
11+ command. setValidFor(365 )
12+ mlAppDeployer. commands. add(command)
13+ }
Original file line number Diff line number Diff line change 1+ <certificate-template-properties xmlns =" http://marklogic.com/manage" >
2+ <template-name >python-test-ssl-template</template-name >
3+ <template-description >Used for marklogic-python-client testing</template-description >
4+ <key-type >rsa</key-type >
5+ <key-options />
6+ <req >
7+ <version >0</version >
8+ <subject >
9+ <countryName >US</countryName >
10+ <stateOrProvinceName >VA</stateOrProvinceName >
11+ <localityName >McLean</localityName >
12+ <organizationName >MarkLogic</organizationName >
13+ <organizationalUnitName >Engineering</organizationalUnitName >
14+ <emailAddress >python@marklogic.com</emailAddress >
15+ </subject >
16+ </req >
17+ </certificate-template-properties >
Original file line number Diff line number Diff line change 1+ {
2+ "user-name" : " python-test-user" ,
3+ "password" : " password" ,
4+ "role" : [
5+ " rest-reader" ,
6+ " rest-writer" ,
7+ " qconsole-user"
8+ ]
9+ }
10+
Original file line number Diff line number Diff line change 1+ {
2+ "server-name" : " %%NAME%%-ssl" ,
3+ "group-name" : " Default" ,
4+ "server-type" : " http" ,
5+ "enabled" : true ,
6+ "root" : " /" ,
7+ "port" : 8031 ,
8+ "authentication" : " digestbasic" ,
9+ "content-database" : " %%DATABASE%%" ,
10+ "modules-database" : " %%MODULES_DATABASE%%" ,
11+ "ssl-certificate-template" : " python-test-ssl-template" ,
12+ "url-rewriter" : " /MarkLogic/rest-api/rewriter.xml" ,
13+ "error-handler" : " /MarkLogic/rest-api/error-handler.xqy" ,
14+ "rewrite-resolves-globally" : true
15+ }
16+
Original file line number Diff line number Diff line change 22from requests .auth import HTTPDigestAuth
33
44
5- def test_get_search_response_with_no_args ():
5+ def test_search ():
66 response = requests .get (
7- "http://localhost:8030/v1/search" , auth = HTTPDigestAuth ("admin" , "admin" )
7+ "http://localhost:8030/v1/search" ,
8+ auth = HTTPDigestAuth ("python-test-user" , "password" )
89 )
910 assert 200 == response .status_code
1011 assert "application/xml; charset=utf-8" == response .headers ["Content-type" ]
Original file line number Diff line number Diff line change 1+ import requests
2+
3+
4+ def test_verify_false ():
5+ """
6+ The certificate verification in requests is fairly picky; while it's possible to disable
7+ hostname validation, I did not find a way to ask it to not care about self-signed certificates.
8+ So for now, this is just verifying that verify=False works with a MarkLogic app server that is
9+ using a self-signed certificate. In the real world, a customer would have a real certificate and
10+ would configure "verify" to point to that.
11+ """
12+ response = requests .get (
13+ "https://localhost:8031/v1/search" ,
14+ auth = ("python-test-user" , "password" ),
15+ verify = False ,
16+ headers = {"Accept" : "application/json" },
17+ )
18+ assert 200 == response .status_code
19+ assert "application/json; charset=utf-8" == response .headers ["Content-type" ]
20+ data = response .json ()
21+ assert (
22+ 10 == data ["page-length" ]
23+ ), "Just verifying that a JSON search response is returned"
You can’t perform that action at this time.
0 commit comments