public void RegisterNewRegionFromConfigFileTest() { Region.ResetConfigFileInUse(); string regionBlob = "[{ \"realmKey\" : \"RTC\",\"realmDomainComponent\" : \"foobar-oraclecloud.com\",\"regionKey\" : \"atl\",\"regionIdentifier\" : \"ap-atl-1\"}]"; DirectoryInfo dir = Directory.CreateDirectory(FileUtils.ExpandUserHome(Path.Combine("~", ".oci"))); var regionConfigFilePath = FileUtils.ExpandUserHome(Path.Combine("~", ".oci", "regions-config.json")); try { File.WriteAllText(regionConfigFilePath, regionBlob); if (File.Exists(regionConfigFilePath)) { Region regionFromConfigFile = Region.FromRegionCodeOrId("atl"); Region US_ATLANTA_TST = Region.Register("ap-atl-1", Realm.Register("RTC", "foobar-oraclecloud.com"), "atl"); Assert.True(AreRegionsSame(regionFromConfigFile, US_ATLANTA_TST)); } } catch (Exception e) { Assert.True(false, $"RegisterNewRegionFromConfigFileTest failed due to exception:{e}"); } finally { File.Delete(regionConfigFilePath); } }
public void RegisterNewRealm() { Realm.Register(NEW_REALM_ID, NEW_SECOND_LEVEL_DOMAIN); var realm = Realm.ValueOf(NEW_REALM_ID); Assert.Equal(NEW_REALM_ID, realm.RealmId); Assert.Equal(NEW_SECOND_LEVEL_DOMAIN, realm.SecondLevelDomain); }
public void ExistingRealmNotRegisteredAgain() { var realmsCount = Realm.Values().Length; Realm.Register(Realm.OC1.RealmId, Realm.OC1.SecondLevelDomain); Assert.Equal(realmsCount, Realm.Values().Length); var realm = Realm.ValueOf(Realm.OC1.RealmId); Assert.Equal(Realm.OC1.RealmId, realm.RealmId); Assert.Equal(Realm.OC1.SecondLevelDomain, realm.SecondLevelDomain); }
public void RegisterNewRegionFromEnvVariable() { Region.ResetEnvironmentVariableInUse(); string regionMetadataEnvVar = "{ \"realmKey\" : \"RTC\",\"realmDomainComponent\" : \"foobar-oraclecloud.com\",\"regionKey\" : \"hhh\",\"regionIdentifier\" : \"us-hhh-1\"}"; Environment.SetEnvironmentVariable("OCI_REGION_METADATA", regionMetadataEnvVar); if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("OCI_REGION_METADATA"))) { Region regionFromEnvVar = Region.FromRegionCodeOrId("hhh"); Region US_HHH_TST = Region.Register("us-hhh-1", Realm.Register("RTC", "foobar-oraclecloud.com"), "hhh"); Assert.True(AreRegionsSame(regionFromEnvVar, US_HHH_TST)); } }
public void CannotRegisterWithExistingRealmIdAndDifferentSecondLevelDomain() { Assert.Throws <ArgumentException>(() => Realm.Register(Realm.OC1.RealmId, NEW_SECOND_LEVEL_DOMAIN)); }