Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix spec compliance #193

Merged
merged 1 commit into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 42 additions & 9 deletions src/KDSoapClient/KDSoapMessageAddressingProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,41 @@ KDSoapMessageAddressingProperties::~KDSoapMessageAddressingProperties()

QString KDSoapMessageAddressingProperties::predefinedAddressToString(KDSoapMessageAddressingProperties::KDSoapAddressingPredefinedAddress address, KDSoapAddressingNamespace addressingNamespace)
{
const QString addressingNS = addressingNamespaceToString(addressingNamespace);
QString prefix = addressingNamespaceToString(addressingNamespace);
switch (addressingNamespace) {
case Addressing200303:
case Addressing200403:
case Addressing200408: {
switch (address) {
case Anonymous:
prefix += QLatin1String("/role");
break;
case Unspecified:
prefix += QLatin1String("/id");
break;
default:
qWarning("Anything but Anonymous or Unspecified has no meaning in ws-addressing 2004/08 and earlier");
return QString();
}
break;
}
default:
break;
}

switch (address) {
case Anonymous:
return addressingNS + QLatin1String("/anonymous");
return prefix + QLatin1String("/anonymous");
case None:
return addressingNS + QLatin1String("/none");
return prefix + QLatin1String("/none");
case Reply:
return addressingNS + QLatin1String("/reply");
return prefix + QLatin1String("/reply");
case Unspecified:
return addressingNS + QLatin1String("/unspecified");
default:
Q_ASSERT(false); // should never happen
return QString();
return prefix + QLatin1String("/unspecified");
}

Q_ASSERT(false); // should never happen
return QString();
}

bool KDSoapMessageAddressingProperties::isWSAddressingNamespace(const QString &namespaceUri)
Expand Down Expand Up @@ -296,7 +317,19 @@ void KDSoapMessageAddressingProperties::writeMessageAddressingProperties(KDSoapN
Q_UNUSED(messageNamespace);
Q_UNUSED(forceQualified);

if (d->destination == predefinedAddressToString(None, d->addressingNamespace)) {
bool supportsNoneAddressing = false;
switch (d->addressingNamespace) {
case Addressing200303:
case Addressing200403:
case Addressing200408:
supportsNoneAddressing = false;
break;
case Addressing200508:
supportsNoneAddressing = true;
break;
}

if (supportsNoneAddressing && d->destination == predefinedAddressToString(None, d->addressingNamespace)) {
return;
}

Expand Down
12 changes: 9 additions & 3 deletions unittests/ws_addressing_support/wsaddressingtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,15 @@ private Q_SLOTS:

QString unspecified = KDSoapMessageAddressingProperties::predefinedAddressToString(KDSoapMessageAddressingProperties::Unspecified);
QCOMPARE(unspecified, QString("http://www.w3.org/2005/08/addressing/unspecified"));

QString none200303 = KDSoapMessageAddressingProperties::predefinedAddressToString(KDSoapMessageAddressingProperties::None, KDSoapMessageAddressingProperties::Addressing200303);
QCOMPARE(none200303, QString("http://schemas.xmlsoap.org/ws/2003/03/addressing/none"));

QString reply200303 = KDSoapMessageAddressingProperties::predefinedAddressToString(KDSoapMessageAddressingProperties::Reply, KDSoapMessageAddressingProperties::Addressing200303);
QCOMPARE(reply200303, QString()); // Reply is not a thing in older than 2005/08

QString anon200303 = KDSoapMessageAddressingProperties::predefinedAddressToString(KDSoapMessageAddressingProperties::Anonymous, KDSoapMessageAddressingProperties::Addressing200303);
QCOMPARE(anon200303, QString("http://schemas.xmlsoap.org/ws/2003/03/addressing/role/anonymous"));

QString unspecified200303 = KDSoapMessageAddressingProperties::predefinedAddressToString(KDSoapMessageAddressingProperties::Unspecified, KDSoapMessageAddressingProperties::Addressing200303);
QCOMPARE(unspecified200303, QString("http://schemas.xmlsoap.org/ws/2003/03/addressing/id/unspecified"));
}

void shouldWriteAProperSoapMessageWithRightsAddressingProperties()
Expand Down