Beispiel #1
0
        public void Logout_パスワードなし()
        {
            // arrange

            // act
            var actual = CavetubeAuth.Logout("CaveTalk", String.Empty, "C9A8B58F00CB4E88A8C884CD9C19B868");

            // assert
            Assert.Fail("例外が発生しませんでした。");
        }
Beispiel #2
0
        public void Login_開発者キーなし()
        {
            // arrange

            // act
            var actual = CavetubeAuth.Login("CaveTalk", "cavetalk", String.Empty);

            // assert
            Assert.Fail("例外が発生しませんでした。");
        }
Beispiel #3
0
        public void Logout_成功()
        {
            // arrange

            // act
            var actual = CavetubeAuth.Logout("CaveTalk", "cavetalk", "C9A8B58F00CB4E88A8C884CD9C19B868");

            // assert
            Assert.AreEqual(true, actual);
        }
Beispiel #4
0
        public void Login_ユーザー名なし()
        {
            // arrange

            // act
            CavetubeAuth.Login(String.Empty, "cavetalk", "C9A8B58F00CB4E88A8C884CD9C19B868");

            // assert
            Assert.Fail("例外が発生しませんでした。");
        }
Beispiel #5
0
        public void Login_成功()
        {
            // arrange

            // act
            var actual = CavetubeAuth.Login("CaveTalk", "cavetalk", "C9A8B58F00CB4E88A8C884CD9C19B868");

            // assert
            Assert.IsFalse(String.IsNullOrEmpty(actual));
        }
Beispiel #6
0
        private void LogoutCavetube()
        {
            var apiKey = this.config.ApiKey;

            if (String.IsNullOrWhiteSpace(apiKey))
            {
                return;
            }

            var userId = this.config.UserId;

            if (String.IsNullOrWhiteSpace(userId))
            {
                throw new ConfigurationErrorsException("UserIdが登録されていません。");
            }

            var password = this.config.Password;

            if (String.IsNullOrWhiteSpace(userId))
            {
                throw new ConfigurationErrorsException("Passwordが登録されていません。");
            }

            var devKey = ConfigurationManager.AppSettings["dev_key"];

            if (String.IsNullOrWhiteSpace(devKey))
            {
                throw new ConfigurationErrorsException("[dev_key]が設定されていません。");
            }
            try {
                var isSuccess = CavetubeAuth.Logout(userId, password, devKey);
                if (isSuccess)
                {
                    this.config.ApiKey   = String.Empty;
                    this.config.UserId   = String.Empty;
                    this.config.Password = String.Empty;
                    this.config.Save();

                    base.OnPropertyChanged("LoginStatus");
                }
            } catch (WebException) {
                MessageBox.Show("ログアウトに失敗しました。");
            }
        }
Beispiel #7
0
        private void Login(Object data)
        {
            this.Cursor = Cursors.Wait;
            try {
                var devKey = ConfigurationManager.AppSettings["dev_key"];
                if (String.IsNullOrWhiteSpace(devKey))
                {
                    throw new ConfigurationErrorsException("[dev_key]が設定されていません。");
                }

                try {
                    var apiKey = CavetubeAuth.Login(this.UserId, this.Password, devKey);
                    if (String.IsNullOrWhiteSpace(apiKey))
                    {
                        this.ErrorMessage = "ログインに失敗しました。";
                        return;
                    }

                    var config = Config.GetConfig();
                    config.ApiKey   = apiKey;
                    config.UserId   = this.UserId;
                    config.Password = this.Password;
                    config.Save();
                } catch (ArgumentException e) {
                    var message = "ログインに失敗しました。";
                    this.ErrorMessage = message;
                    logger.Error(message, e);
                    return;
                } catch (WebException e) {
                    var message = "ログインに失敗しました。";
                    this.ErrorMessage = message;
                    logger.Error(message, e);
                }
            } finally {
                this.Cursor = null;
            }

            if (this.OnClose != null)
            {
                this.OnClose();
            }
        }
Beispiel #8
0
 /// <summary>
 /// <see cref="ICavetubeAuth.Logout(string, string)"/>の説明参照
 /// </summary>
 /// <param name="userId"><see cref="ICavetubeAuth.Logout(string, string)"/>の説明参照</param>
 /// <param name="password"><see cref="ICavetubeAuth.Logout(string, string)"/>の説明参照</param>
 /// <returns><see cref="ICavetubeAuth.Logout(string, string)"/>の説明参照</returns>
 public bool Logout(string userId, string password)
 {
     return(CavetubeAuth.Logout(userId, password));
 }
Beispiel #9
0
 /// <summary>
 /// <see cref="ICavetubeAuth.Login(string, string)"/>の説明参照
 /// </summary>
 /// <param name="userId"><see cref="ICavetubeAuth.Login(string, string)"/>の説明参照</param>
 /// <param name="password"><see cref="ICavetubeAuth.Login(string, string)"/>の説明参照</param>
 /// <returns><see cref="ICavetubeAuth.Login(string, string)"/>の説明参照</returns>
 public string Login(string userId, string password)
 {
     return(CavetubeAuth.Login(userId, password));
 }