//External Namespaces TEST_CASE( "default constructor", "[uri]" ) { Uri uri( "http://crowhurst.ben:[email protected]:80/resources/index.html?q=bear&b=cubs#frag1" ); REQUIRE( uri.get_port( ) == 80 ); REQUIRE( uri.get_path( ) == "/resources/index.html" ); REQUIRE( uri.get_query( ) == "q=bear&b=cubs" ); REQUIRE( uri.get_scheme( ) == "http" ); REQUIRE( uri.get_fragment( ) == "frag1" ); REQUIRE( uri.get_username( ) == "crowhurst.ben" ); REQUIRE( uri.get_password( ) == "ASDFFDSA1234" ); REQUIRE( uri.get_authority( ) == "code.google.com" ); const string value = uri.to_string( ); REQUIRE( value == "http://crowhurst.ben:[email protected]:80/resources/index.html?q=bear&b=cubs#frag1" ); } TEST_CASE( "ipv4 constructor", "[uri]" ) { Uri uri( "http://*****:*****@127.1.1.1:80/resources/index.html?q=bear&b=cubs#frag1" ); const string value = uri.to_string( ); REQUIRE( value == "http://*****:*****@127.1.1.1:80/resources/index.html?q=bear&b=cubs#frag1" ); } TEST_CASE( "ipv6 constructor", "[uri]" ) { Uri uri( "http://*****:*****@[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:80/resources/index.html?q=bear&b=cubs#frag1" );
TEST_CASE( "uri fails to handle file scheme relative paths", "[uri]" ) { multimap< string, string > expectation; Uri relative( "file://certs/server.key", true ); REQUIRE( relative.get_port( ) == 0 ); REQUIRE( relative.get_path( ) == "certs/server.key" ); REQUIRE( relative.get_query( ) == "" ); REQUIRE( relative.get_scheme( ) == "file" ); REQUIRE( relative.get_fragment( ) == "" ); REQUIRE( relative.get_username( ) == "" ); REQUIRE( relative.get_password( ) == "" ); REQUIRE( relative.get_authority( ) == "" ); REQUIRE( relative.is_relative( ) == true ); REQUIRE( relative.is_absolute( ) == false ); REQUIRE( relative.to_string( ) == "file://certs/server.key" ); REQUIRE( relative.get_query_parameters( ) == expectation ); Uri absolute( "file:///certs/server.key" ); REQUIRE( absolute.get_port( ) == 0 ); REQUIRE( absolute.get_path( ) == "/certs/server.key" ); REQUIRE( absolute.get_query( ) == "" ); REQUIRE( absolute.get_scheme( ) == "file" ); REQUIRE( absolute.get_fragment( ) == "" ); REQUIRE( absolute.get_username( ) == "" ); REQUIRE( absolute.get_password( ) == "" ); REQUIRE( absolute.get_authority( ) == "" ); REQUIRE( absolute.is_relative( ) == false ); REQUIRE( absolute.is_absolute( ) == true ); REQUIRE( absolute.to_string( ) == "file:///certs/server.key" ); REQUIRE( absolute.get_query_parameters( ) == expectation );
void SSLSettings::set_temporary_diffie_hellman( const Uri& value ) { m_pimpl->temporary_diffie_hellman = String::remove( "file://", value.to_string( ), String::CASE_INSENSITIVE ); }
void SSLSettings::set_private_rsa_key( const Uri& value ) { m_pimpl->private_rsa_key = String::remove( "file://", value.to_string( ), String::CASE_INSENSITIVE ); }
void SSLSettings::set_certificate_authority_pool( const Uri& value ) { m_pimpl->certificate_authority_pool = String::remove( "file://", value.to_string( ), String::CASE_INSENSITIVE ); }
void SSLSettings::set_certificate_chain( const Uri& value ) { m_pimpl->m_certificate_chain = String::remove( "file://", value.to_string( ), String::CASE_INSENSITIVE ); }