7
Hello, I have an authentication service already mounted in c# and wanted to do any test with it. It can be a webform page, which returns a positive or negative, or a class c# even if it runs per console and does the same. Already has all the structure mounted, just consume, I already have a password on web.config with md5. is using SOAP the service.
namespace Test.Services
{
/// <summary>
/// Summary description for TestService
/// </summary>
[WebService(Namespace = "http://www.este.com.br", Description = "Servico de interface com o sistema de gerenciamento eletronico de documentos")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class TestService : System.Web.Services.WebService
{
[WebMethod(Description="Metodo que adiciona um arquivo a base do Test")]
public void AddArquivo(Autenticacao aut, Arquivo arq)
{
Autenticar(aut);
ArquivoController.GetInstance().AddArquivo(arq);
}
[WebMethod]
public Arquivo GetArquivo(Autenticacao autenticacao)
{
return null;
}
/// <summary>
/// Método que executa a autenticação dos utilizadores do webservices
/// </summary>
/// <param name="aut">Objeto contendo a autenticação</param>
private void Autenticar(Autenticacao aut)
{
if (string.Compare(aut.Usuario, Util.Util.WebConfigurations.GetValue("usuariowebservice")) != 0 || string.Compare(Util.Util.GUIDs.GetKeyMD5(aut.Senha), Util.Util.WebConfigurations.GetValue("senhawebservice")) != 0)
throw new TestServiceException("Usuário e/ou senha inválido(s)");
}
}
/// <summary>
/// Classe que do objeto de autenticação dos usuários do serviço
/// </summary>
public class Autenticacao
{
public string Usuario { get; set; }
public string Senha { get; set; }
}
}
How to create a test class, to try to authenticate with any password? only test.
I just wanted to draw attention to one point.
(...)já tenho uma senha no web.config com md5(...)
I don’t know why, but if it’s for security reasons, it’s a wasted effort.– Oralista de Sistemas