aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/tvmauth/client/misc/utils.cpp
blob: a124c7b11cd32900e1a38997c1759ec1c6d6a15c (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
#include "utils.h"

#include <library/cpp/tvmauth/client/facade.h>

#include <util/stream/format.h>

namespace NTvmAuth::NInternal {
    void TClientCaningKnife::StartTvmClientStopping(TTvmClient* c) {
        if (c && c->Updater_) {
            c->Updater_->StartTvmClientStopping();
        }
    }

    bool TClientCaningKnife::IsTvmClientStopped(TTvmClient* c) {
        return c && c->Updater_ ? c->Updater_->IsTvmClientStopped() : true;
    }
}

namespace NTvmAuth::NUtils {
    TString ToHex(const TStringBuf s) {
        TStringStream res;
        res.Reserve(2 * s.size());

        for (char c : s) {
            res << Hex(c, HF_FULL);
        }

        return std::move(res.Str());
    }

    bool CheckBbEnvOverriding(EBlackboxEnv original, EBlackboxEnv override) noexcept {
        switch (original) {
            case EBlackboxEnv::Prod:
            case EBlackboxEnv::ProdYateam:
                return override == EBlackboxEnv::Prod || override == EBlackboxEnv::ProdYateam;
            case EBlackboxEnv::Test:
                return true;
            case EBlackboxEnv::TestYateam:
                return override == EBlackboxEnv::Test || override == EBlackboxEnv::TestYateam;
            case EBlackboxEnv::Stress:
                return override == EBlackboxEnv::Stress;
        }

        return false;
    }
}