protected async Task ReauthorizeAsync()
        {
            var newToken = await this.IntegrationAdminTokenRepository.GetTokenAsync(MagentoLogin.Create(this.ApiUser), MagentoPass.Create(this.ApiKey)).ConfigureAwait(false);

            var magentoUrl = MagentoUrl.Create(this.Store);

            this.ProductRepository          = new ProductRepository(newToken, magentoUrl);
            this.CatalogStockItemRepository = new CatalogStockItemRepository(newToken, magentoUrl);
            this.SalesOrderRepository       = new SalesOrderRepositoryV1(newToken, magentoUrl);
        }
 public async Task <AuthorizationToken> GetTokenAsync(MagentoLogin token, MagentoPass url)
 {
     return(await ActionPolicies.RepeatOnChannelProblemAsync.Get(async() =>
     {
         using (var v = await(( WebRequest )
                              WebRequest.Create()
                              .Method(MagentoWebRequestMethod.Post)
                              .Url(this.Url)
                              .Path(MagentoServicePath.CreateIntegrationServicePath())
                              .Body(JsonConvert.SerializeObject(new CredentialsModel()
         {
             username = token.Login, password = url.Password
         })))
                        .RunAsync(Mark.CreateNew()).ConfigureAwait(false))
         {
             return AuthorizationToken.Create(new StreamReader(v, Encoding.UTF8).ReadToEnd());
         }
     }).ConfigureAwait(false));
 }
Exemplo n.º 3
0
        public static IEnumerable GetCliTestStoreCredentials()
        {
            string url      = TestContext.Parameters["url"];
            string login    = TestContext.Parameters["login"];
            string password = TestContext.Parameters["password"];

            if (!string.IsNullOrWhiteSpace(url) &&
                !string.IsNullOrWhiteSpace(login) &&
                !string.IsNullOrWhiteSpace(password))
            {
                return new TestCaseData[] { new TestCaseData(new RepositoryTestCase()
                    {
                        Url = MagentoUrl.Create(url), MagentoLogin = MagentoLogin.Create(login), MagentoPass = MagentoPass.Create(password)
                    }) }
            }
            ;

            return(null);
        }
    }