コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
 public void CannotRegisterWithExistingRealmIdAndDifferentSecondLevelDomain()
 {
     Assert.Throws <ArgumentException>(() => Realm.Register(Realm.OC1.RealmId, NEW_SECOND_LEVEL_DOMAIN));
 }