public void TestReadSettings() {
      MockAppConfig config = new MockAppConfig();
      config.MockReadSettings(tblSettings);
      NetworkCredential credential = (NetworkCredential) config.Proxy.Credentials;
      Assert.AreEqual(tblSettings["ProxyUser"].ToString(), credential.UserName);
      Assert.AreEqual(tblSettings["ProxyPassword"].ToString(), credential.Password);
      Assert.AreEqual(tblSettings["ProxyDomain"].ToString(), credential.Domain);
      Assert.AreEqual(bool.Parse(tblSettings["MaskCredentials"].ToString()),
          config.MaskCredentials);
      Assert.AreEqual(int.Parse(tblSettings["Timeout"].ToString()), config.Timeout);
      Assert.AreEqual(int.Parse(tblSettings["RetryCount"].ToString()), config.RetryCount);

      Assert.AreEqual(tblSettings["OAuth2ClientId"].ToString(), config.OAuth2ClientId);
      Assert.AreEqual(tblSettings["OAuth2ClientSecret"].ToString(), config.OAuth2ClientSecret);
      Assert.AreEqual(tblSettings["OAuth2ServiceAccountEmail"].ToString(),
          config.OAuth2ServiceAccountEmail);
      Assert.AreEqual(tblSettings["OAuth2PrnEmail"].ToString(), config.OAuth2PrnEmail);
      Assert.AreEqual(tblSettings["OAuth2AccessToken"].ToString(), config.OAuth2AccessToken);
      Assert.AreEqual(tblSettings["OAuth2RefreshToken"].ToString(), config.OAuth2RefreshToken);
      Assert.AreEqual(tblSettings["OAuth2Scope"].ToString(), config.OAuth2Scope);
      Assert.AreEqual(tblSettings["OAuth2RedirectUri"].ToString(), config.OAuth2RedirectUri);
      Assert.AreEqual(tblSettings["OAuth2JwtCertificatePath"].ToString(),
          config.OAuth2CertificatePath);
      Assert.AreEqual(tblSettings["OAuth2JwtCertificatePassword"].ToString(),
          config.OAuth2CertificatePassword);
      Assert.AreEqual(tblSettings["OAuth2Mode"].ToString(), config.OAuth2Mode.ToString());

      Assert.AreEqual(tblSettings["Email"].ToString(), config.Email);
      Assert.AreEqual(tblSettings["Password"].ToString(), config.Password);
      Assert.AreEqual(tblSettings["AuthToken"].ToString(), config.AuthToken);
      Assert.AreEqual(bool.Parse(tblSettings["EnableGzipCompression"].ToString()),
          config.EnableGzipCompression);
    }
 public void TestTimeout()
 {
     MockAppConfig config = new MockAppConfig();
       config.Timeout = 20;
       Assert.AreEqual(20, config.Timeout);
 }
 public void TestSignature()
 {
     MockAppConfig config = new MockAppConfig();
       Assert.NotNull(config.Signature);
 }
 public void TestRetryCount()
 {
     MockAppConfig config = new MockAppConfig();
       config.RetryCount = 20;
       Assert.AreEqual(20, config.RetryCount);
 }
 public void TestReadSettingsForDefaults()
 {
     Assert.DoesNotThrow(delegate() {
     MockAppConfig config = new MockAppConfig();
     config.MockReadSettings(null);
       });
 }
Пример #6
0
 /// <summary>
 /// Overloaded constructor.
 /// </summary>
 /// <param name="config">The configuration class.</param>
 public MockAdsUser(MockAppConfig config)
     : base(config)
 {
 }
    public void Init() {
      tblSettings = new Hashtable();

      tblSettings.Add("OAuth2ClientId", "OAuth2ClientId");
      tblSettings.Add("OAuth2ClientSecret", "OAuth2ClientSecret");
      tblSettings.Add("OAuth2AccessToken", "OAuth2AccessToken");
      tblSettings.Add("OAuth2RefreshToken", "OAuth2RefreshToken");
      tblSettings.Add("OAuth2Scope", "OAuth2Scope");
      tblSettings.Add("OAuth2RedirectUri", "OAuth2RedirectUri");

      appConfig = new MockAppConfig();
      appConfig.MockReadSettings(tblSettings);
      provider = new OAuth2ProviderForApplications(appConfig);
      oauth2RequestInterceptor.Intercept = true;
    }
Пример #8
0
 /// <summary>
 /// Overloaded constructor.
 /// </summary>
 /// <param name="config">The configuration class.</param>
 public MockAdsUser(MockAppConfig config)
   : base(config) {
 }
    public void Init() {
      tblSettings = new Hashtable();
      tblSettings.Add("OAuth2ClientId", "OAuth2ClientId");
      tblSettings.Add("OAuth2ClientSecret", "OAuth2ClientSecret");
      tblSettings.Add("OAuth2ServiceAccountEmail", "OAuth2ServiceAccountEmail");
      tblSettings.Add("OAuth2PrnEmail", "OAuth2PrnEmail");

      tblSettings.Add("OAuth2AccessToken", "OAuth2AccessToken");
      tblSettings.Add("OAuth2Scope", "OAuth2Scope");
      tblSettings.Add("OAuth2RedirectUri", "OAuth2RedirectUri");
      string tempCertificatePath = Path.GetTempFileName();
      using (FileStream fs = File.OpenWrite(tempCertificatePath)) {
        fs.Write(Resources.certificate, 0, Resources.certificate.Length);
      }
      tblSettings.Add("OAuth2JwtCertificatePath", tempCertificatePath);
      tblSettings.Add("OAuth2JwtCertificatePassword", "notasecret");

      appConfig = new MockAppConfig();
      appConfig.MockReadSettings(tblSettings);
      provider = new OAuth2ProviderForServiceAccounts(appConfig);
      oauth2RequestInterceptor.Intercept = true;
    }