#include "zypp/base/Exception.h"
#include "zypp/base/String.h"
+#include "zypp/RepoInfo.h"
+
#include "zypp/Url.h"
#include <stdexcept>
#include <iostream>
BOOST_CHECK_EQUAL( str, url.asString() );
BOOST_CHECK_EQUAL( str, url.asCompleteString() );
- // asString & asCompleteString should add empty authority
- // "dvd://...", except we request to avoid it.
- str = "dvd:/srv/ftp";
- one = "dvd:///srv/ftp";
- two = "dvd:///srv/ftp";
- url = str;
+ // In general, schema without authority allows specifying an empty authority
+ // though it should not be printed (unless explicitly requested).
+ BOOST_CHECK_EQUAL( Url("dvd:/srv/ftp").asCompleteString(), "dvd:/srv/ftp" );
+ BOOST_CHECK_EQUAL( Url("dvd:/srv/ftp").asString(), "dvd:/srv/ftp" );
- BOOST_CHECK_EQUAL( one, url.asString() );
- BOOST_CHECK_EQUAL( two, url.asCompleteString() );
- BOOST_CHECK_EQUAL( str, url.asString(zypp::url::ViewOptions() -
- zypp::url::ViewOption::EMPTY_AUTHORITY));
+ BOOST_CHECK_EQUAL( Url("dvd:///srv/ftp").asCompleteString(), "dvd:/srv/ftp" );
+ BOOST_CHECK_EQUAL( Url("dvd:///srv/ftp").asString(), "dvd:/srv/ftp" );
+
+ BOOST_CHECK_EQUAL( Url("dvd:///srv/ftp").asString(url::ViewOption::DEFAULTS+url::ViewOption::EMPTY_AUTHORITY), "dvd:///srv/ftp" );
+ BOOST_CHECK_EQUAL( Url("dvd:///srv/ftp").asString(url::ViewOption::DEFAULTS-url::ViewOption::EMPTY_AUTHORITY), "dvd:/srv/ftp" );
+
+ BOOST_CHECK_THROW( Url("dvd://authority/srv/ftp"), url::UrlNotAllowedException );
// asString shouldn't print the password, asCompleteString should
// further, the "//" at the begin of the path should become "/%2F"
// OK, valid (no host, path is there)
str = "cd:///some/path";
- BOOST_CHECK_EQUAL( str, zypp::Url(str).asString());
BOOST_CHECK( zypp::Url(str).isValid());
}
BOOST_CHECK_EQUAL( Url(zypp::url::encode( str, URL_SAFE_CHARS )).asString(), str );
}
+BOOST_AUTO_TEST_CASE(plugin_scriptpath)
+{
+ // plugin script path must not be rewritten
+ for ( const std::string & t : { "script", "script/", "/script", "/script/", "./script", "./script/" } )
+ {
+ BOOST_CHECK_EQUAL( Url("plugin:"+t).getPathName(), t );
+ }
+
+ { // more cosmetic issue, but the RepoVarReplacer should
+ // not change the string representation (-> "plugin:/script")
+ Url u( "plugin:script?opt=val" );
+ RepoInfo i;
+ i.setBaseUrl( u );
+ BOOST_CHECK_EQUAL( u.asString(), i.url().asString() );
+ }
+
+}
+
BOOST_AUTO_TEST_CASE(plugin_querystring_args)
{
// url querysting options without value must be possible