aboutsummaryrefslogtreecommitdiff
path: root/unittest/test2.cc
blob: 79417c63d1e3586547e6884d5f4ad78ca64aa74f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#define CATCH_CONFIG_MAIN  // This tells Catch to provide a main()
#include "catch.hpp"

#include <iostream>
#include <string.h>
#include <NitrokeyManager.h>
#include "device_proto.h"
#include "log.h"
//#include "stick10_commands.h"
#include "stick20_commands.h"

using namespace std;
using namespace nitrokey::device;
using namespace nitrokey::proto;
using namespace nitrokey::proto::stick20;
using namespace nitrokey::log;
using namespace nitrokey::misc;


TEST_CASE("test", "[test]") {
  Stick20 stick;
  bool connected = stick.connect();
  REQUIRE(connected == true);

  Log::instance().set_loglevel(Loglevel::DEBUG_L2);

  stick10::LockDevice::CommandTransaction::run(stick);
//  {
//    auto p = get_payload<EnableEncryptedPartition>();
//    p.set_kind_user();
//    strcpyT(p.password, "123456");
//    EnableEncryptedPartition::CommandTransaction::run(stick, p);
//  }
// {
//    auto p = get_payload<DisableEncryptedPartition>();
//    p.set_kind_user();
//    strcpyT(p.password, "123456");
//    DisableEncryptedPartition::CommandTransaction::run(stick, p);
//  }

  {
    auto p = get_payload<EnableEncryptedPartition>();
    p.set_kind_user();
    strcpyT(p.password, "123456");
    EnableEncryptedPartition::CommandTransaction::run(stick, p);
  }
  {
    auto p = get_payload<EnableHiddenEncryptedPartition>();
    p.set_kind_user();
    strcpyT(p.password, "123123123");
    EnableHiddenEncryptedPartition::CommandTransaction::run(stick, p);
  }
  this_thread::sleep_for(1000ms);
  stick10::LockDevice::CommandTransaction::run(stick);

  stick.disconnect();
}