aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/tvmauth/client/mocked_updater.cpp
blob: 6da02c43d1a47413886cc7ab1d9a5302ed15abee (plain) (blame)
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
58
59
60
#include "mocked_updater.h" 
 
#include <library/cpp/tvmauth/unittest.h> 
 
namespace NTvmAuth { 
    TMockedUpdater::TSettings TMockedUpdater::TSettings::CreateDeafult() { 
        TMockedUpdater::TSettings res; 
 
        res.SelfTvmId = 100500; 
 
        res.Backends = { 
            { 
                /*.Alias_ = */ "my_dest", 
                /*.Id_ = */ 42, 
                /*.Value_ = */ "3:serv:CBAQ__________9_IgYIlJEGECo:O9-vbod_8czkKrpwJAZCI8UgOIhNr2xKPcS-LWALrVC224jga2nIT6vLiw6q3d6pAT60g9K7NB39LEmh7vMuePtUMjzuZuL-uJg17BsH2iTLCZSxDjWxbU9piA2T6u607jiSyiy-FI74pEPqkz7KKJ28aPsefuC1VUweGkYFzNY", 
            }, 
        }; 
 
        res.BadBackends = { 
            { 
                /*.Alias_ = */ "my_bad_dest", 
                /*.Id_ = */ 43, 
                /*.Value_ = */ "Dst is not found", 
            }, 
        }; 
 
        return res; 
    } 
 
    TMockedUpdater::TMockedUpdater(const TSettings& settings) 
        : Roles_(settings.Roles) 
    { 
        SetServiceContext(MakeIntrusiveConst<TServiceContext>(TServiceContext::CheckingFactory( 
            settings.SelfTvmId, 
            NUnittest::TVMKNIFE_PUBLIC_KEYS))); 
 
        SetBbEnv(settings.UserTicketEnv); 
        SetUserContext(NUnittest::TVMKNIFE_PUBLIC_KEYS); 
 
        TServiceTickets::TMapIdStr tickets, errors; 
        TServiceTickets::TMapAliasId aliases; 
 
        for (const TSettings::TTuple& t : settings.Backends) { 
            tickets[t.Id] = t.Value; 
            aliases[t.Alias] = t.Id; 
        } 
        for (const TSettings::TTuple& t : settings.BadBackends) { 
            errors[t.Id] = t.Value; 
            aliases[t.Alias] = t.Id; 
        } 
 
        SetServiceTickets(MakeIntrusiveConst<TServiceTickets>( 
            std::move(tickets), 
            std::move(errors), 
            std::move(aliases))); 
 
        SetUpdateTimeOfPublicKeys(TInstant::Now()); 
        SetUpdateTimeOfServiceTickets(TInstant::Now()); 
    } 
}