Ejemplo n.º 1
0
        public void BoxConfig_SetUriString()
        {
            const string JsonString =
                @"{
              'boxAppSettings': {
                'clientID': 'cid-123',
                'clientSecret': 'cre-123',
                'appAuth': {
                  'publicKeyID': 'kid-123',
                  'privateKey': 'testKey',
                  'passphrase': 'password'
                },
              },
              'webhooks': {},
              'enterpriseID': 'eid-123'
            }";
            var config = BoxConfigBuilder
                         .CreateFromJsonString(JsonString)
                         .Build();

            Assert.AreEqual(config.BoxApiUri, new Uri(Constants.BoxApiUriString));

            var exampleUri = new Uri("https://example.com/");

            config = BoxConfigBuilder.CreateFromJsonString(JsonString)
                     .SetBoxApiUri(exampleUri)
                     .Build();
            Assert.AreEqual(config.BoxApiUri, exampleUri);
        }
Ejemplo n.º 2
0
        public void BoxConfig_CreateFromString()
        {
            const string JsonString =
                @"{
              'boxAppSettings': {
                'clientID': 'cid-123',
                'clientSecret': 'cre-123',
                'appAuth': {
                  'publicKeyID': 'kid-123',
                  'privateKey': 'testKey',
                  'passphrase': 'password'
                },
              },
              'webhooks': {},
              'enterpriseID': 'eid-123'
            }";
            var config = BoxConfigBuilder.CreateFromJsonString(JsonString)
                         .Build();

            Assert.AreEqual(config.ClientId, "cid-123");
            Assert.AreEqual(config.ClientSecret, "cre-123");
            Assert.AreEqual(config.JWTPublicKeyId, "kid-123");
            Assert.AreEqual(config.JWTPrivateKey, "testKey");
            Assert.AreEqual(config.EnterpriseId, "eid-123");
        }
Ejemplo n.º 3
0
        public static async Task AssemblyInitialize(TestContext testContext)
        {
            var jsonConfig = Environment.GetEnvironmentVariable("INTEGRATION_TESTING_CONFIG");

            if (string.IsNullOrEmpty(jsonConfig))
            {
                Debug.WriteLine("No json config found in environment variables Reading from config.json.");
                jsonConfig = ReadFromJson("config.json");
            }

            var config = BoxConfigBuilder.CreateFromJsonString(jsonConfig)
                         .Build();
            var session = new BoxJWTAuth(config);

            var json       = JObject.Parse(jsonConfig);
            var adminToken = await session.AdminTokenAsync();

            AdminClient = session.AdminClient(adminToken);

            if (json["userID"] != null && json["userID"].ToString().Length != 0)
            {
                UserId = json["userID"].ToString();
            }
            else
            {
                var user = await CreateNewUser(AdminClient);

                UserId = user.Id;
            }
            var userToken = await session.UserTokenAsync(UserId);

            UserClient = session.UserClient(userToken, UserId);

            EnterpriseId = config.EnterpriseId;
        }
Ejemplo n.º 4
0
        private static void Main()
        {
            var boxConfig = BoxConfigBuilder.CreateFromJsonString(GetConfigJson())
                            // Set web proxy
                            .SetWebProxy(new BoxHttpProxy())
                            .Build();

            var boxJWT = new BoxJWTAuth(boxConfig);

            var adminToken  = boxJWT.AdminTokenAsync().Result;
            var adminClient = boxJWT.AdminClient(adminToken);

            _ = adminClient.FoldersManager.GetFolderItemsAsync("0", 500).Result;
        }