/** * In devstack and going forward, namespaces are being deprecated. When namespace is missing (or * replaced with a "fake" /fake namespace), allow matching by name and alias. */ public void testPresentWhenNameSpaceIsFakeAndMatchByNameOrAlias() throws SecurityException, NoSuchMethodException { // Revert to alias Extension floatingIpsWithFakeNamespace = floatingIps.toBuilder().namespace(URI.create("http://docs.openstack.org/ext/fake")).build(); // Revert to name Extension floatingIpsWithFakeNamespaceAndAlias = floatingIps .toBuilder() .namespace(URI.create("http://docs.openstack.org/ext/fake")) .alias("fake") .build(); Multimap<URI, URI> aliases = ImmutableMultimap.of(); assertEquals( whenExtensionsAndAliasesInRegionInclude( "region", ImmutableSet.of(floatingIpsWithFakeNamespace), aliases) .apply(getFloatingIPExtension(ImmutableList.<Object>of("region"))), Optional.of("foo")); assertEquals( whenExtensionsAndAliasesInRegionInclude( "region", ImmutableSet.of(floatingIpsWithFakeNamespaceAndAlias), aliases) .apply(getFloatingIPExtension(ImmutableList.<Object>of("region"))), Optional.of("foo")); }
/** * It is possible that the /extensions call returned the correct extension, but that the * namespaces were different, for whatever reason. One way to address this is to have a multimap * of the authoritative namespace to alternate ones, which could be wired up with guice */ public void testPresentWhenAliasForExtensionMapsToNamespace() throws SecurityException, NoSuchMethodException { Extension keypairsWithDifferentNamespace = keypairs .toBuilder() .namespace( URI.create("http://docs.openstack.org/ext/arbitrarilydifferent/keypairs/api/v1.1")) .build(); Multimap<URI, URI> aliases = ImmutableMultimap.of( keypairs.getNamespace(), keypairsWithDifferentNamespace.getNamespace()); assertEquals( whenExtensionsAndAliasesInRegionInclude( "region", ImmutableSet.of(keypairsWithDifferentNamespace), aliases) .apply(getKeyPairExtension(ImmutableList.<Object>of("region"))), Optional.of("foo")); assertEquals( whenExtensionsAndAliasesInRegionInclude( "region", ImmutableSet.of(keypairsWithDifferentNamespace), aliases) .apply(getFloatingIPExtension(ImmutableList.<Object>of("region"))), Optional.absent()); }