if (!sec)
goto cleanup;
+ /* NB: NONE is a byproduct of the qemuxml2argvtest test mocking
+ * for UUID lookups. Normal secret XML processing would fail if
+ * the usage type was NONE and since we have no way to set the
+ * expected usage in that environment, let's just accept NONE */
+ if (sec->usageType != VIR_SECRET_USAGE_TYPE_NONE &&
+ sec->usageType != secretUsageType) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+ virUUIDFormat(seclookupdef->u.uuid, uuidstr);
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("secret with uuid %s is of type '%s' not "
+ "expected '%s' type"),
+ uuidstr, virSecretUsageTypeToString(sec->usageType),
+ virSecretUsageTypeToString(secretUsageType));
+ goto cleanup;
+ }
+
*secret = conn->secretDriver->secretGetValue(sec, secret_size, 0,
VIR_SECRET_GET_VALUE_INTERNAL_CALL);
fakeSecretLookupByUUID(virConnectPtr conn,
const unsigned char *uuid)
{
- return virGetSecret(conn, uuid, 0, "");
+ /* NB: This mocked value could be "tls" or "volume" depending on
+ * which test is being run, we'll leave at NONE (or 0) */
+ return virGetSecret(conn, uuid, VIR_SECRET_USAGE_TYPE_NONE, "");
}
static virSecretDriver fakeSecretDriver = {