summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkarl <karl>2005-08-01 15:19:50 +0000
committerkarl <karl>2005-08-01 15:19:50 +0000
commitf29d6c1d1dd32e61b7bf37fbf7dc7d32bb8838db (patch)
tree64fdd30fe1ceb5a3c523d998e3d69499ad533cc9 /src
parentcdfad9ab461acd7d375be56fce73700d4fefe25a (diff)
downloadtog-pegasus-f29d6c1d1dd32e61b7bf37fbf7dc7d32bb8838db.zip
tog-pegasus-f29d6c1d1dd32e61b7bf37fbf7dc7d32bb8838db.tar.gz
tog-pegasus-f29d6c1d1dd32e61b7bf37fbf7dc7d32bb8838db.tar.xz
BUG#: 3696
TITLE: Interop Provider Should use Interop Namespace DESCRIPTION: Modify Provider and tests to force use of the interop namespace
Diffstat (limited to 'src')
-rw-r--r--src/Pegasus/ControlProviders/InteropProvider/InteropProvider.cpp98
-rw-r--r--src/Pegasus/ControlProviders/InteropProvider/tests/interop.cpp205
2 files changed, 226 insertions, 77 deletions
diff --git a/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.cpp b/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.cpp
index 8ec2268..6f3bfda 100644
--- a/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.cpp
+++ b/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.cpp
@@ -69,7 +69,8 @@
// CIM_NamespaceInManager
// ...
// Interop forces all creates to the PEGASUS_NAMESPACENAME_INTEROP
-// namespace.
+// namespace. There is a test on each operation that returns
+// the Invalid Class CIMDError
// This is a control provider and as such uses the Tracer functions
// for data and function traces. Since we do not expect high volume
// use we added a number of traces to help diagnostics.
@@ -266,35 +267,17 @@ InteropProvider::InteropProvider(CIMRepository* repository)
// do it's inalization work. This fix sets StatisticalData::CopyGSD, enabling the
//statistical gathering function.
-
Boolean InstancesExists = true;
Array<CIMInstance> instance;
try
- {
- instance = repository->enumerateInstances(CIMNamespaceName("root/cimv2"),
- CIMName ("CIM_ObjectManager"));
+ {
+ instance = repository->enumerateInstances(PEGASUS_NAMESPACENAME_INTEROP,
+ CIM_OBJECTMANAGER_CLASSNAME);
}
catch(Exception e)
{
- InstancesExists = false;
- }
-
- /* When Bug 3696 is fixed the following try block will replace the try block above. But for
- now if no instances of the CIM_ObjectManager class are found in the root/cimv2 name space
- the root/PG_InterOp name space will be checked
- */
- if(!InstancesExists)
- {
- try
- {
- instance = repository->enumerateInstances(CIMNamespaceName("root/PG_InterOp"),
- CIMName ("CIM_ObjectManager"));
- }
- catch(Exception e)
- {
- InstancesExists = false;
- }
+ InstancesExists = false;
}
if(instance.size() > 0 && InstancesExists)
@@ -319,7 +302,6 @@ InteropProvider::InteropProvider(CIMRepository* repository)
}
}
}
- //******************************************* end of temporary fix
PEG_METHOD_EXIT();
}
@@ -344,7 +326,31 @@ static String _toStringPropertyList(const CIMPropertyList& pl)
return(tmp);
}
-
+/** Determines if the namespace is allowable for this operation.
+ This provider is designed to accept either all namespaces or
+ limit itself to just one for operations. In all cases, it
+ will provide the required answers and use the correct namespace
+ for any persistent information. However, it may be configured
+ to either accept input operations from any namespace or simply
+ from one (normally the interop namespace).
+ @ objectReference for the operation. This must include the
+ namespace and class name for the operation.
+ @return Returns normally if the namespace test is passed. Otherwise
+ it generates a CIMException (CIM_ERR_NOT_SUPPORTED)
+ @exception CIMException(CIM_ERR_NOT_SUPPORTED)
+*/
+void _isNamespaceAllowed(const CIMObjectPath & path)
+{
+ // To allow use of all namespaces, uncomment the following line
+ // return;
+ if (path.getNameSpace().getString() != PEGASUS_NAMESPACENAME_INTEROP)
+ {
+ throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
+ path.getClassName().getString());
+ }
+ else
+ return;
+}
/* set the hostname and namespace fields into the cimobjectpath
of the defined instance
*/
@@ -1898,10 +1904,10 @@ void InteropProvider::createInstance(
thisProvider,
(const char *) instanceReference.toString().getCString());
- handler.processing();
+ // test for legal namespace for this provider. Exception if not
+ _isNamespaceAllowed(instanceReference);
- // operation namespace needed internally to get class.
- // KS_TEMP _operationNamespace = instanceReference.getNameSpace();
+ handler.processing();
// Verify that ClassName is correct and get value
targetClass classEnum = _verifyValidClassInput(instanceReference.getClassName());
@@ -2063,7 +2069,9 @@ void InteropProvider::deleteInstance(
thisProvider,
(const char *) instanceName.toString().getCString());
- // KS_TEMP _operationNamespace = instanceName.getNameSpace();
+ // test for legal namespace for this provider. Exception if not
+ _isNamespaceAllowed(instanceName);
+
handler.processing();
// Verify that ClassName is correct and get value
targetClass classEnum = _verifyValidClassInput(instanceName.getClassName());
@@ -2203,8 +2211,11 @@ void InteropProvider::getInstance(
const CIMPropertyList & propertyList,
InstanceResponseHandler & handler)
{
+ // test for legal namespace for this provider. Exception if not
+ _isNamespaceAllowed(instanceName);
+
handler.processing();
-
+
CIMInstance myInstance = localGetInstance(
context,
instanceName,
@@ -2232,8 +2243,6 @@ Array<CIMInstance> InteropProvider::localEnumerateInstances(
const Boolean includeQualifiers,
const Boolean includeClassOrigin,
const CIMPropertyList& propertyList)
-{
-
{
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::localEnumerateInstances()");
@@ -2245,7 +2254,6 @@ Array<CIMInstance> InteropProvider::localEnumerateInstances(
(const char*) _showBool(includeClassOrigin).getCString(),
(const char *)_showPropertyList(propertyList).getCString());
-
// Verify that ClassName is correct and get value
targetClass classEnum = _verifyValidClassInput(ref.getClassName());
@@ -2315,7 +2323,6 @@ Array<CIMInstance> InteropProvider::localEnumerateInstances(
return(instances);
PEG_METHOD_EXIT();
}
-}
//***************************************************************************
// EnumerateInstances - External Operation call
@@ -2331,6 +2338,9 @@ void InteropProvider::enumerateInstances(
{
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::enumerateInstances()");
+ // test for legal namespace for this provider. Exception if not
+ _isNamespaceAllowed(ref);
+
handler.processing();
// Call the internal enumerateInstances to generate instances of defined
@@ -2435,6 +2445,9 @@ void InteropProvider::modifyInstance(const OperationContext & context,
(const char *) _showBool(includeQualifiers).getCString(),
(const char *) _showPropertyList(propertyList).getCString());
+ // test for legal namespace for this provider. Exception if not
+ _isNamespaceAllowed(instanceReference);
+
// ATTN: KS 31 August 2004. This must test for privileged user.
CIMName className = instanceReference.getClassName();
@@ -2504,6 +2517,9 @@ void InteropProvider::enumerateInstanceNames(
thisProvider,
(const char *) classReference.toString().getCString());
+ // test for legal namespace for this provider. Exception if not
+ _isNamespaceAllowed(classReference);
+
targetClass classEnum =
_verifyValidClassInput(classReference.getClassName());
@@ -2616,6 +2632,10 @@ void InteropProvider::associators(
(const char *)_showBool(includeQualifiers).getCString(),
(const char*) _showBool(includeClassOrigin).getCString(),
(const char *)_showPropertyList(propertyList).getCString());
+
+ // test for legal namespace for this provider. Exception if not
+ _isNamespaceAllowed(objectName);
+
handler.processing();
// Get references for this object. Note that this
// uses the associationClass as resultClass.
@@ -2684,6 +2704,9 @@ void InteropProvider::associatorNames(
"InteropProvider::associatorNames()");
//throw CIMNotSupportedException("AssociationProvider::associatorNames");
+ // test for legal namespace for this provider. Exception if not
+ _isNamespaceAllowed(objectName);
+
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
"%s associatorNames. objectName= %s , assocClass= %s resultClass= %s role= %s resultRole",
thisProvider,
@@ -2795,6 +2818,9 @@ void InteropProvider::references(
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
"InteropProvider::references()");
+ // test for legal namespace for this provider. Exception if not
+ _isNamespaceAllowed(objectName);
+
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
"%s references. objectName= %s , resultClass= %s role= %s includeQualifiers= %s, includeClassOrigin= %s, PropertyList= %s",
thisProvider,
@@ -2828,6 +2854,10 @@ void InteropProvider::referenceNames(
{
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
"InteropProvider::referenceNames()");
+
+ // test for legal namespace for this provider. Exception if not
+ _isNamespaceAllowed(objectName);
+
CDEBUG("::referenceNames(): object= " << objectName.toString() << " result Class= " << resultClass.getString());
// operation namespace needed internally to get class.
diff --git a/src/Pegasus/ControlProviders/InteropProvider/tests/interop.cpp b/src/Pegasus/ControlProviders/InteropProvider/tests/interop.cpp
index fa2fb81..e23ed52 100644
--- a/src/Pegasus/ControlProviders/InteropProvider/tests/interop.cpp
+++ b/src/Pegasus/ControlProviders/InteropProvider/tests/interop.cpp
@@ -62,7 +62,7 @@ PEGASUS_USING_STD;
// Macro puts out message and then does assert error out.
#define TERMINATE(X) {PEGASUS_STD(cout) << "TestInterop " << X << PEGASUS_STD(endl); assert(false);}
#define CDEBUG(X)
-//#define CDEBUG(X) PEGASUS_STD(cout) << "InteropTest " << X << PEGASUS_STD(endl)
+//#define CDEBUG(X) PEGASUS_STD(cout) << "InteropTest(" << __LINE__ << ")" << X << PEGASUS_STD(endl)
#include <cstring>
#include <stdcxx/stream/strstream>
@@ -211,7 +211,8 @@ public:
Boolean _namespaceCreatePG_Namespace(const CIMNamespaceName& name);
- Boolean _namespaceCreateCIM_Namespace(const CIMNamespaceName& name);
+ Boolean _namespaceCreateCIM_Namespace(const CIMNamespaceName& name,
+ const CIMNamespaceName& targetNamespace);
Boolean _testPGNamespace(const CIMNamespaceName& name,
Boolean shared,
@@ -397,14 +398,12 @@ Boolean InteropTest::testGetInstancesForEnum(const Array<CIMObjectPath>& paths,
// Get every instance to confirm that it is gettable
for (Uint32 i = 0 ; i < paths.size() ; i++)
{
- cout << "InstancePath= " << paths[i].toString() << endl;
CIMInstance instance = _client.getInstance(PEGASUS_NAMESPACENAME_INTEROP,
paths[i],
localOnly,
includeQualifiers,
includeClassOrigin,
propertyList);
- cout << "Return" << endl;
for (Uint32 j = 0; instances.size() ; j++)
{
if (instance.getPath() == instances[j].getPath())
@@ -485,7 +484,7 @@ Boolean InteropTest::testEnumerateOptions(
for (Uint32 i = 0 ; i < instance.getPropertyCount() ; i++)
{
- CDEBUG("testEnumerations 1a" << " prpertycount= " << instance.getProperty(i).getName().getString());
+ CDEBUG("testEnumerations 1a" << " propertycount= " << instance.getProperty(i).getName().getString());
nameList.append(instance.getProperty(i).getName());
}
@@ -1055,7 +1054,14 @@ Boolean InteropTest::_namespaceCreate__Namespace(const CIMNamespaceName& parent,
return(true);
}
-/** Create a single namespace using CIM_Namespace
+/** Create a single namespace using PG_Namespace. Creates the namespace with
+ the name defined in the call by creating a new instance of PG_Namespace.
+ @param name - CIMNamespaceName of namespace to create.
+ @param CIMNamespaceName ns is optional parameter that defines the name
+ of the CIMServer namespace to be used as the target for the instance
+ create. This option is only used to test for ability to create namespaces
+ in other than the defined interop namespace.
+ @return - true if creeate. False if not created or if it already exists.
*/
Boolean InteropTest::_namespaceCreatePG_Namespace(const CIMNamespaceName& name)
{
@@ -1098,7 +1104,6 @@ Boolean InteropTest::_namespaceCreatePG_Namespace(const CIMNamespaceName& name)
instance.removeProperty(pos);
instance.addProperty(p);
- CDEBUG("Creating instance for " << localName << " in namespace " << InteropNamespace);
if (verbose)
{
cout << "Show instance used to do namespace create: " << endl;
@@ -1111,8 +1116,9 @@ Boolean InteropTest::_namespaceCreatePG_Namespace(const CIMNamespaceName& name)
}
catch(Exception& e)
{
- // ATTN: Temp bypass to do checkin.
- cerr << "Error during Creation of " << name.getString() << ": " << e.getMessage()
+ cerr << "Error during Creation of " << name.getString()
+ << " in Namespace " << InteropNamespace
+ << ": " << e.getMessage()
<< " Instance Creation error" << endl;
return(false);
}
@@ -1120,13 +1126,23 @@ Boolean InteropTest::_namespaceCreatePG_Namespace(const CIMNamespaceName& name)
return(true);
}
-/** Create a single namespace using CIM_Namespace
+/** Create a single namespace using CIM_Namespace.
+ @param name CIMNamespaceName of namespace to create
+ @param target CIMNamespaceName of namespace in which we issue
+ the command to create the namespace. This paramater is primarily
+ to test if we can issue this operation in namespaces other than the
+ interop namespace.
*/
-Boolean InteropTest::_namespaceCreateCIM_Namespace(const CIMNamespaceName& name)
+Boolean InteropTest::_namespaceCreateCIM_Namespace(const CIMNamespaceName& name,
+ const CIMNamespaceName& targetNamespace)
{
// Does this namespace exist.
if (_existsNew(name))
+ {
+ cout << "Namespace " << name.getString() <<
+ " already Exists in _namespacCreateCIM_Namespace function." << endl;
return(false);
+ }
//Now build the new namespace name instance. Note that we need to get the
// collection of keys that are required. Easy way was to simply
@@ -1144,7 +1160,6 @@ Boolean InteropTest::_namespaceCreateCIM_Namespace(const CIMNamespaceName& name)
CIMInstance newInstance(CIM_NAMESPACE_CLASSNAME);
-
for (Uint32 i = 0 ; i < instance.getQualifierCount() ; i++)
{
newInstance.addQualifier(instance.getQualifier(i).clone());
@@ -1187,7 +1202,6 @@ Boolean InteropTest::_namespaceCreateCIM_Namespace(const CIMNamespaceName& name)
instance.removeProperty(pos);
instance.addProperty(p);
- CDEBUG("Creating instance for " << localName << " in namespace " << InteropNamespace);
if (verbose)
{
cout << "Show instance used to do namespace create: " << endl;
@@ -1196,29 +1210,36 @@ Boolean InteropTest::_namespaceCreateCIM_Namespace(const CIMNamespaceName& name)
try
{
CIMObjectPath path;
- path = _client.createInstance(InteropNamespace, instance);
+ path = _client.createInstance(targetNamespace, instance);
+ }
+ catch(CIMException& e)
+ {
+ if ((e.getCode() != CIM_ERR_INVALID_CLASS) && (e.getCode() != CIM_ERR_NOT_SUPPORTED))
+ {
+ cerr << "CIMException during Creation of " << name.getString()
+ << " in namespace " << targetNamespace
+ << ": " << e.getMessage()
+ << " CIM_Namespace Instance Creation error" << endl;
+ }
+ return(false);
}
catch(Exception& e)
{
- cerr << "Error during Creation of " << name.getString() << ": " << e.getMessage()
- << " Instance Creation error" << endl;
+ cerr << "Exception during Creation of " << name.getString()
+ << ": " << e.getMessage()
+ << " CIM_Namespace Instance Creation error" << endl;
return(false);
}
return(true);
}
-//ATTN: This test is not done and therefore always returns true.
-// 28 Sept 2004. KS.
Boolean InteropTest::_testPGNamespace(const CIMNamespaceName& name,
Boolean shared, Boolean updatesAllowed, const String& parent)
{
- //ATTN: Build the get and test properties.
-
-
// get the instance
// We only get PG Namespaces because these characteristics would
// not exist for any CIMNamespace.
- // TODO: There should NOT be and CIMNamespaces so we should be able
+ // TODO: There should NOT be any CIMNamespaces so we should be able
// to enumerate at that level successfully.
Array<CIMObjectPath> paths = _getPGNamespaceInstanceNames();
CIMInstance instance;
@@ -1238,8 +1259,7 @@ Boolean InteropTest::_testPGNamespace(const CIMNamespaceName& name,
false, //lo
true, //includeQualifiers
true, //includeClassOrigin
-
- CIMPropertyList());
+ CIMPropertyList());
}
//
// Match the properties in the instance against the method inputs.
@@ -1292,14 +1312,20 @@ Boolean InteropTest::_testPGNamespace(const CIMNamespaceName& name,
return(true);
}
-/** Create a single namespace using PG_Namespace
+/** Create a single namespace using PG_Namespace. Creates namespace with the
+ options for shareable, updatesAllowed, and parent. This allows testing
+ of creation of shared namespaces
*/
Boolean InteropTest::_namespaceCreatePG_Namespace(const CIMNamespaceName& name,
const Boolean shareable, const Boolean updatesAllowed, const String& parent)
{
// Does this namespace exist.
if (_existsNew(name))
+ {
+ cout << "Namespace " << name.getString() <<
+ " already Exists in _namespacCreatePG_Namespace function." << endl;
return(false);
+ }
//Now build the new namespace name instance. Note that we need to get the
// collection of keys that are required. Easy way was to simply
@@ -1382,8 +1408,8 @@ Boolean InteropTest::_namespaceCreatePG_Namespace(const CIMNamespaceName& name,
}
catch(Exception& e)
{
- // ATTN: Temp bypass to do checkin.
- cerr << "Error during Creation of " << name.getString() << ": " << e.getMessage()
+ cerr << "Error during Creation of " << name.getString()
+ << ": " << e.getMessage()
<< " Instance Creation error" << endl;
return(false);
}
@@ -1487,17 +1513,20 @@ void InteropTest::testNameSpacesManagement()
cout << "Error exit, Invalid namespace returned" << endl;
}
- if(verbose)
- {
- _showNamespaceList(nameListNew, "From CIM_Namespace");
-
- _showNamespaceList(nameListOld, "From __Namespace");
+ BubbleSort(nameListNew);
+ BubbleSort(nameListOld);
+ if(verbose) {
+ _showNamespaceList(nameListNew, "Using CIM_Namespace");
+ _showNamespaceList(nameListOld, "Using __Namespace");
}
assert(nameListNew.size() == nameListOld.size());
// Add assertion that they have the same items in the list
-
+ for (Uint32 i = 0 ; i < nameListNew.size() ; i++)
+ {
+ assert(nameListNew[i] == nameListOld[i]);
+ }
// Create a new namespace with new functions
CIMNamespaceName testNameNew = CIMNamespaceName("root/junk/interoptest/newtype");
@@ -1507,13 +1536,22 @@ void InteropTest::testNameSpacesManagement()
// Create the namespace with the PG_Namespace class
// Note that this is an assertion and, in fact, we should probably remove the names
- // to clean up the repository after the test TODO
+ // to clean up the repository after the test. If they do exist here. TODO
+
+ // Clean up the names we will use just to be sure.
+ if (_existsNew(testNameNew)) {
+ _namespaceDeleteCIM_Namespace(testNameNew);
+ }
+
+ if (_existsNew(testNameOldComplete)) {
+ _namespaceDeleteCIM_Namespace(testNameOldComplete);
+ }
assert( ! _existsNew(testNameNew));
assert( ! _existsNew(testNameOldComplete));
- CDEBUG("Now Create New Namespace with PG_Namespace. Namespace name = " << testNameNew.getString() << ".");
+ CDEBUG("Create New Namespace with PG_Namespace. Namespace name = " << testNameNew.getString() << ".");
_namespaceCreatePG_Namespace(CIMNamespaceName(testNameNew));
@@ -1543,7 +1581,7 @@ void InteropTest::testNameSpacesManagement()
CDEBUG("Now Create New Namespace with CIM_Namespace. Namespace name = " << testNameNew.getString() << ".");
- _namespaceCreateCIM_Namespace(CIMNamespaceName(testNameNew));
+ assert(_namespaceCreateCIM_Namespace(CIMNamespaceName(testNameNew), InteropNamespace));
if (verbose)
_showNamespaceList(nameListNew, "CIM_Namespace response after add. with PG_Namespace");
@@ -1558,7 +1596,7 @@ void InteropTest::testNameSpacesManagement()
//
// Create namespace with __Namespace
//
- CDEBUG("Creating Old = " << testNameOldTail.getString());
+ CDEBUG("Creating with __Namespace appending " << testNameOldTail.getString() << " to " << testNameOldRoot.getString());
_namespaceCreate__Namespace(CIMNamespaceName(testNameOldRoot), String(testNameOldTail.getString()));
assert(_existsNew(testNameOldComplete));
@@ -1595,13 +1633,38 @@ void InteropTest::testNameSpacesManagement()
if(_existsNew(CIMNamespaceName(testNameOldComplete)))
cerr << "Problem deleting namespace" << endl;
- // Finally test to be sure that we have the same count of namespaces
+ //
+ // Test to be sure we cannot create new namespaces anywhere but in the
+ // Interop namespace
+ //
+ Array<CIMNamespaceName> namespaceList = _getNamespacesNew();
+ for (Uint32 i = 0 ; i < namespaceList.size() ; i++)
+ {
+ // The get class test is here simply as a means to assure that no
+ // instances exist in the any namespace except the interop namespace
+ if (!(namespaceList[i] == InteropNamespace))
+ {
+ // Error if we can successfully create namespace.
+ if (_namespaceCreateCIM_Namespace(CIMNamespaceName(testNameNew), namespaceList[i]))
+ {
+ cout << "Error, Created new CIM_Namespace " << testNameNew.getString()
+ << " instance in " << namespaceList[i].getString() << endl;
+ TERMINATE("Failed test by creating new namespace outside of Interop namespace");
+ }
+ }
+ }
+ // Test to be sure that we have the same count of namespaces
//as when we started. Should also check to be sure it is exactly the
//same set of namespaces.
-
- Array<CIMNamespaceName> nameListTemp = _getNamespacesNew();
-
- assert(nameListTemp.size() == nameListNew.size());
+ Array<CIMNamespaceName> finalNamespaceList = _getNamespacesNew();
+ if (finalNamespaceList.size() != nameListNew.size())
+ {
+ BubbleSort(finalNamespaceList);
+ BubbleSort(nameListNew);
+ _showNamespaceList(nameListNew, " Namespaces Before Namespace test");
+ _showNamespaceList(finalNamespaceList, " Namespaces After Namespace test");
+ TERMINATE("Error. Did not clean all namespaces");
+ }
if (verbose)
cout << "Basic Namespace Tests passed" << endl;
@@ -1628,7 +1691,7 @@ void InteropTest::testSharedNameSpacesManagement()
_namespaceCreatePG_Namespace(testNameShared, false, false, testNameSharable.getString());
// create a namespace with the previous sharable as parent.
- _namespaceCreateCIM_Namespace(testNameNotShared);
+ assert(_namespaceCreateCIM_Namespace(testNameNotShared, InteropNamespace));
// Confirm that both exist
assert(_existsNew(testNameSharable));
assert(_existsNew(testNameShared));
@@ -1657,6 +1720,8 @@ void InteropTest::testSharedNameSpacesManagement()
{
cout << "SharedNamespace sizes " << nameListBefore.size()
<< " " << nameListAfter.size() << endl;
+ BubbleSort(nameListBefore);
+ BubbleSort(nameListAfter);
_showNamespaceList(nameListBefore, "Before");
_showNamespaceList(nameListAfter, "After");
assert(nameListBefore.size() == nameListAfter.size());
@@ -1712,6 +1777,8 @@ CIMObjectPath InteropTest::getObjMgrPath()
//****************************************************************
void InteropTest::testObjectManagerClass()
{
+ if (verbose)
+ cout << "testOjectManagerClass() test Start." << endl;
try
{
@@ -1810,6 +1877,58 @@ void InteropTest::testObjectManagerClass()
{
TERMINATE(" CIM_ObjectManager Caught General Exception:");
}
+
+ //
+ // Test to be sure we cannot get instances of this class from another
+ // namespace
+ //
+ Boolean errFound = false;
+ Array<CIMNamespaceName> namespaceList = _getNamespacesNew();
+
+ // for all namespaces not PG_interop, try to get CIM_ObjectManager
+ // results should always be zero.
+ for (Uint32 i = 0 ; i < namespaceList.size() ; i++)
+ {
+ // for all namespaces except interop, try to enumerate
+ // instances of cimobjectmanager.
+ if (namespaceList[i] != InteropNamespace)
+ {
+ try
+ {
+ Array <CIMObjectPath> paths = _client.enumerateInstanceNames(
+ namespaceList[i],
+ CIM_OBJECTMANAGER_CLASSNAME);
+ assert(paths.size() == 0);
+ }
+ // Catch block for this enum test. We test class not exist.
+ catch(CIMException& e)
+ {
+ if ((e.getCode() != CIM_ERR_INVALID_CLASS) && (e.getCode() != CIM_ERR_NOT_SUPPORTED))
+ {
+ cout << " CIMException " << e.getMessage()
+ << "namespace " << namespaceList[i].getString()
+ << "EnumerateInstances of CIMObjectManager "
+ << endl;
+ errFound = true;
+ }
+ }
+ catch(Exception& e)
+ {
+ errFound= true;
+ cout << "Exception in look for cimobject manager in strange places " <<
+ e.getMessage() << endl;
+ }
+ catch(...)
+ {
+ errFound = true;
+ cout << "Exception in look for cimobject manager in strange places" << endl;
+ }
+ }
+ }
+ if (errFound)
+ {
+ TERMINATE("Error: CImObjectManager instance should not exist other than PG_Interop namespace");
+ }
if (verbose)
cout << "ObjectManagerClass Tests passed" << endl;
}