Skip to content

Commit

Permalink
Tests - Add KeyringTests
Browse files Browse the repository at this point in the history
  • Loading branch information
nlogozzo committed Dec 9, 2023
1 parent db78daa commit 42e15dd
Showing 1 changed file with 43 additions and 10 deletions.
53 changes: 43 additions & 10 deletions tests/keyringtests.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,51 @@
#include <gtest/gtest.h>
#include <iostream>
#include "keyring/keyring.h"
#include "keyring/passwordgenerator.h"

using namespace Nickvision::Aura::Keyring;

TEST(KeyringTests, PasswordGen1)
class KeyringTest : public testing::Test
{
PasswordGenerator gen;
std::string pass1 = gen.next();
std::string pass2 = gen.next();
std::string pass3 = gen.next(6);
std::cout << pass1 << std::endl << pass2 << std::endl << pass3 << std::endl;
EXPECT_EQ(pass1.length(), 16);
EXPECT_EQ(pass2.length(), 16);
EXPECT_EQ(pass3.length(), 6);
EXPECT_FALSE(pass1 == pass2);
public:
PasswordGenerator m_passGen;
std::shared_ptr<Keyring> m_keyring;

KeyringTest()
{
std::optional<Keyring> keyring{ Keyring::access("org.nickvision.auratests") };
if (keyring.has_value())
{
m_keyring = std::make_shared<Keyring>(keyring.value());
}
}
};

TEST_F(KeyringTest, KeyringInitalization)
{
ASSERT_TRUE(m_keyring);
}

TEST_F(KeyringTest, AddCredential1)
{
ASSERT_TRUE(m_keyring);
ASSERT_TRUE(m_keyring->addCredential({ "YT", "https://youtube.com", "test1", m_passGen.next() }));
}

TEST_F(KeyringTest, AddCredential2)
{
ASSERT_TRUE(m_keyring);
ASSERT_TRUE(m_keyring->addCredential({ "GitHub", "https://github.com", "test2", m_passGen.next() }));
}

TEST_F(KeyringTest, FetchCredentials)
{
ASSERT_TRUE(m_keyring);
ASSERT_TRUE(m_keyring->getAllCredentials().size() == 2);
}

TEST_F(KeyringTest, KeyringDestroy)
{
ASSERT_TRUE(m_keyring);
ASSERT_TRUE(m_keyring->destroy());
}

0 comments on commit 42e15dd

Please sign in to comment.