MCPcopy Create free account
hub / github.com/cutelyst/cutelyst / getEngine

Method getEngine

tests/testauthentication.cpp:160–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160TestEngine *TestAuthentication::getEngine()
161{
162 auto app = new TestApplication;
163 auto engine = new TestEngine(app, QVariantMap());
164
165 auto auth = new Authentication(app);
166
167 auto clearStore = std::make_shared<StoreMinimal>(u"id"_s);
168 {
169 AuthenticationUser fooUser(u"foo"_s);
170 fooUser.insert(u"password"_s, u"123"_s);
171 clearStore->addUser(fooUser);
172
173 AuthenticationUser barUser(u"bar"_s);
174 barUser.insert(u"password"_s, u"321"_s);
175 clearStore->addUser(barUser);
176 }
177 auto clearPassword = std::make_shared<CredentialPassword>();
178 clearPassword->setPasswordField(u"password"_s);
179 clearPassword->setPasswordType(CredentialPassword::Clear);
180 auth->addRealm(std::make_shared<AuthenticationRealm>(clearStore, clearPassword));
181
182 const auto preSalt = QStringLiteral(u"preSalt");
183 const auto postSalt = QStringLiteral(u"postSalt");
184
185 auto hashedStore = std::make_shared<StoreMinimal>(u"id"_s);
186 {
187 AuthenticationUser fooUser(u"foo"_s);
188 fooUser.insert(u"password"_s,
189 CredentialPassword::createPassword(preSalt + u"123" + postSalt));
190 hashedStore->addUser(fooUser);
191
192 AuthenticationUser barUser(u"bar"_s);
193 barUser.insert(u"password"_s,
194 CredentialPassword::createPassword(preSalt + u"321" + postSalt));
195 hashedStore->addUser(barUser);
196 }
197
198 auto hashedPassword = std::make_shared<CredentialPassword>();
199 hashedPassword->setPasswordField(u"password"_s);
200 hashedPassword->setPasswordType(CredentialPassword::Hashed);
201 hashedPassword->setPasswordPreSalt(preSalt);
202 hashedPassword->setPasswordPostSalt(postSalt);
203
204 auth->addRealm(std::make_shared<AuthenticationRealm>(hashedStore, hashedPassword, u"hashed"_s));
205
206 auto nonePassword = std::make_shared<CredentialPassword>();
207 nonePassword->setPasswordField(u"password"_s);
208 nonePassword->setPasswordType(CredentialPassword::None);
209 auth->addRealm(std::make_shared<AuthenticationRealm>(clearStore, nonePassword, u"none"_s));
210
211 auto clearHttpCredential = std::make_shared<CredentialHttp>();
212 clearHttpCredential->setPasswordType(CredentialHttp::Clear);
213 clearHttpCredential->setUsernameField(u"id"_s);
214 auth->addRealm(
215 std::make_shared<AuthenticationRealm>(clearStore, clearHttpCredential, u"httpClear"_s));
216
217 auto hashedHttpCredential = std::make_shared<CredentialHttp>();

Callers

nothing calls this directly

Calls 9

insertMethod · 0.80
addRealmMethod · 0.80
setUsernameFieldMethod · 0.80
addUserMethod · 0.45
setPasswordFieldMethod · 0.45
setPasswordTypeMethod · 0.45
setPasswordPreSaltMethod · 0.45
setPasswordPostSaltMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected