コード例 #1
0
ファイル: CliTests.cs プロジェクト: ebekker/keypear
    public async Task Toplevel_Help()
    {
        var cli = new CliTester();
        await cli.InitAsync();

        var ret = await cli.InvokeAsync("--help");

        Assert.Equal(0, ret);
    }
コード例 #2
0
ファイル: CliTests.cs プロジェクト: ebekker/keypear
    public async Task Register_New_Account()
    {
        using var cli = new CliTester();
        await cli.InitAsync();

        var ret = await cli.InvokeAsync("reg", "--email", "*****@*****.**", "--password", "foobar");

        Assert.Equal(0, ret);

        var sessionKey = cli.Console.OutWriter.GetStringBuilder().ToString();

        Assert.NotEmpty(sessionKey);
    }
コード例 #3
0
ファイル: CliTests.cs プロジェクト: ebekker/keypear
    public async Task Create_Vaults()
    {
        using var cli = new CliTester();
        await cli.InitAsync();

        int ret;

        ret = await cli.InvokeAsync("reg", "--email", "*****@*****.**", "--password", "foobar", "--raw-session");

        Assert.Equal(0, ret);

        var sessionKey = cli.ReadOut();

        Assert.NotEmpty(sessionKey);

        cli.SetEnv("KYPR_SESSION", sessionKey);

        ret = await cli.InvokeAsync("list", "vaults");

        Assert.Equal(0, ret);

        var output = cli.ReadOut();

        Assert.NotEmpty(output);

        var vaults = JsonSerializer.Deserialize <ListVaultsCommand.ListVaultsOutput>(output);

        Assert.Empty(vaults !.Vaults);

        ret += await cli.InvokeAsync("new", "vault", "--label", "v1");

        ret += await cli.InvokeAsync("new", "vault", "--label", "v2");

        ret += await cli.InvokeAsync("new", "vault", "--label", "v3");

        var vaultIds = cli.ReadOut().Trim().Split(Environment.NewLine);

        Assert.Equal(3, vaultIds.Length);

        ret += await cli.InvokeAsync("list", "vaults");

        Assert.Equal(0, ret);

        output = cli.ReadOut();
        vaults = JsonSerializer.Deserialize <ListVaultsCommand.ListVaultsOutput>(output);
        Assert.Equal(3, vaults !.Vaults.Count);

        Assert.True(vaults.Vaults.All(x => vaultIds.Contains(x.Id.ToString())));
        Assert.True(vaultIds.All(x => vaults.Vaults.Any(y => y.Id.ToString() == x)));
    }