#include "base_command.h"

#include <gtest/gtest.h>

class AuthenticateNativeAppTest : public BaseCommandTest {
 public:
  AuthenticateNativeAppTest() {
  }
  virtual ~AuthenticateNativeAppTest() {
  }
};

TEST_F(AuthenticateNativeAppTest, 01_AuthenticationWithPendingStatus_Passed) {
  TciCommand tci_command = {0};

  tci_command.cmdId = kTestSimpleAuthenticate;
  tci_command.handler = handler;

  TEEC_Result status = SendCommand(tci_command);
  ASSERT_EQ((TEEC_Result)TEEC_SUCCESS, status) << "Error is occurred during test execution";
  // TODO(i.vorobiov): Change to strict assert after porting Zero to async FIVE
  ASSERT_TRUE(PA_TZ_AF_INTEGRITY_IS_NOT_READY == tci_command.tz_result ||
      PA_TZ_SUCCESS == tci_command.tz_result) <<
    "Simple authentication SHOULD return pending status on async FIVE device\n"
    "Simple authentication SHOULD return success on sync FIVE device\n";

  sleep(1);

  status = SendCommand(tci_command);
  ASSERT_EQ((TEEC_Result)TEEC_SUCCESS, status) << "Error is occurred during test execution";
  ASSERT_EQ(PA_TZ_SUCCESS, tci_command.tz_result) <<
    "Simple authentication SHOULD be authenticated after delay of one second";
}
