Lines Matching refs:uid
132 int setUpSocketAndTag(int protocol, uint64_t* cookie, uint32_t tag, uid_t uid, in setUpSocketAndTag() argument
138 EXPECT_EQ(0, mTc.tagSocket(sock, tag, uid, callingUid)); in setUpSocketAndTag()
142 void expectUidTag(uint64_t cookie, uid_t uid, uint32_t tag) { in expectUidTag() argument
145 EXPECT_EQ(uid, tagResult.value().uid); in expectUidTag()
151 void populateFakeStats(uint64_t cookie, uint32_t uid, uint32_t tag, StatsKey* key) { in populateFakeStats() argument
152 UidTagValue cookieMapkey = {.uid = (uint32_t)uid, .tag = tag}; in populateFakeStats()
154 *key = {.uid = uid, .tag = tag, .counterSet = TEST_COUNTERSET, .ifaceIndex = 1}; in populateFakeStats()
157 EXPECT_RESULT_OK(mFakeUidCounterSetMap.writeValue(uid, counterSet, BPF_ANY)); in populateFakeStats()
161 EXPECT_RESULT_OK(mFakeAppUidStatsMap.writeValue(uid, statsMapValue, BPF_ANY)); in populateFakeStats()
167 uint32_t uid = TEST_UID; in checkUidOwnerRuleForChain() local
168 EXPECT_EQ(0, mTc.changeUidOwnerRule(chain, uid, DENY, DENYLIST)); in checkUidOwnerRuleForChain()
169 Result<UidOwnerValue> value = mFakeUidOwnerMap.readValue(uid); in checkUidOwnerRuleForChain()
173 uid = TEST_UID2; in checkUidOwnerRuleForChain()
174 EXPECT_EQ(0, mTc.changeUidOwnerRule(chain, uid, ALLOW, ALLOWLIST)); in checkUidOwnerRuleForChain()
175 value = mFakeUidOwnerMap.readValue(uid); in checkUidOwnerRuleForChain()
179 EXPECT_EQ(0, mTc.changeUidOwnerRule(chain, uid, DENY, ALLOWLIST)); in checkUidOwnerRuleForChain()
180 value = mFakeUidOwnerMap.readValue(uid); in checkUidOwnerRuleForChain()
184 uid = TEST_UID; in checkUidOwnerRuleForChain()
185 EXPECT_EQ(0, mTc.changeUidOwnerRule(chain, uid, ALLOW, DENYLIST)); in checkUidOwnerRuleForChain()
186 value = mFakeUidOwnerMap.readValue(uid); in checkUidOwnerRuleForChain()
190 uid = TEST_UID3; in checkUidOwnerRuleForChain()
191 EXPECT_EQ(-ENOENT, mTc.changeUidOwnerRule(chain, uid, ALLOW, DENYLIST)); in checkUidOwnerRuleForChain()
192 value = mFakeUidOwnerMap.readValue(uid); in checkUidOwnerRuleForChain()
198 for (uint32_t uid : uids) { in checkEachUidValue() local
199 Result<UidOwnerValue> value = mFakeUidOwnerMap.readValue(uid); in checkEachUidValue()
225 uint32_t uid = stoi(strUid); in expectUidOwnerMapValues() local
226 Result<UidOwnerValue> value = mFakeUidOwnerMap.readValue(uid); in expectUidOwnerMapValues()
229 << "Expected rule for UID " << uid << " to be " << expectedRule << ", but was " in expectUidOwnerMapValues()
232 << "Expected iif for UID " << uid << " to be " << expectedIif << ", but was " in expectUidOwnerMapValues()
245 for (uid_t uid : appUids) { in expectUidPermissionMapValues() local
246 Result<uint8_t> value = mFakeUidPermissionMap.readValue(uid); in expectUidPermissionMapValues()
249 << "Expected value for UID " << uid << " to be " << expectedValue in expectUidPermissionMapValues()
257 for (uid_t uid : appUids) { in expectPrivilegedUserSet() local
258 EXPECT_NE(mTc.mPrivilegedUser.end(), mTc.mPrivilegedUser.find(uid)); in expectPrivilegedUserSet()
267 void addPrivilegedUid(uid_t uid) { in addPrivilegedUid() argument
268 std::vector privilegedUid = {uid}; in addPrivilegedUid()
272 void removePrivilegedUid(uid_t uid) { in removePrivilegedUid() argument
273 std::vector privilegedUid = {uid}; in removePrivilegedUid()
277 void expectFakeStatsUnchanged(uint64_t cookie, uint32_t tag, uint32_t uid, in expectFakeStatsUnchanged() argument
281 EXPECT_EQ(uid, cookieMapResult.value().uid); in expectFakeStatsUnchanged()
283 Result<uint8_t> counterSetResult = mFakeUidCounterSetMap.readValue(uid); in expectFakeStatsUnchanged()
295 auto appStatsResult = mFakeAppUidStatsMap.readValue(uid); in expectFakeStatsUnchanged()
301 void expectTagSocketReachLimit(uint32_t tag, uint32_t uid) { in expectTagSocketReachLimit() argument
307 EXPECT_EQ(-EMFILE, mTc.tagSocket(sock, tag, uid, uid)); in expectTagSocketReachLimit()
311 EXPECT_EQ(0, mTc.deleteTagData(0, uid, 0)); in expectTagSocketReachLimit()
312 EXPECT_EQ(0, mTc.tagSocket(sock, tag, uid, uid)); in expectTagSocketReachLimit()
313 expectUidTag(sockCookie, uid, tag); in expectTagSocketReachLimit()
414 uid_t uid = TEST_UID; in TEST_F() local
419 populateFakeStats(cookie, uid, tag, &tagStatsMapKey[i]); in TEST_F()
431 uid_t uid = TEST_UID + i; in TEST_F() local
432 populateFakeStats(cookie, uid, tag, &tagStatsMapKey[i]); in TEST_F()
443 uid_t uid = TEST_UID; in TEST_F() local
444 Result<uint8_t> counterSetResult = mFakeUidCounterSetMap.readValue(uid); in TEST_F()
448 ASSERT_FALSE(mFakeUidCounterSetMap.readValue(uid).ok()); in TEST_F()
456 uid_t uid = TEST_UID; in TEST_F() local
457 ASSERT_FALSE(mFakeUidCounterSetMap.readValue(uid).ok()); in TEST_F()
467 uid_t uid = TEST_UID; in TEST_F() local
468 ASSERT_FALSE(mFakeUidCounterSetMap.readValue(uid).ok()); in TEST_F()
476 uid_t uid = TEST_UID; in TEST_F() local
479 populateFakeStats(cookie, uid, tag, &tagStatsMapKey); in TEST_F()
482 expectFakeStatsUnchanged(cookie, tag, uid, tagStatsMapKey); in TEST_F()
491 uid_t uid = TEST_UID; in TEST_F() local
494 populateFakeStats(cookie, uid, tag, &tagStatsMapKey); in TEST_F()
497 Result<uint8_t> counterSetResult = mFakeUidCounterSetMap.readValue(uid); in TEST_F()
518 uid_t uid = TEST_UID; in TEST_F() local
521 populateFakeStats(cookie, uid, tag, &tagStatsMapKey); in TEST_F()
524 ASSERT_FALSE(mFakeUidCounterSetMap.readValue(uid).ok()); in TEST_F()
538 uid_t uid = TEST_UID; in TEST_F() local
543 populateFakeStats(cookie1, uid, tag1, &tagStatsMapKey1); in TEST_F()
544 populateFakeStats(cookie2, uid, tag2, &tagStatsMapKey2); in TEST_F()
549 ASSERT_EQ(TEST_UID, cookieMapResult.value().uid); in TEST_F()
551 Result<uint8_t> counterSetResult = mFakeUidCounterSetMap.readValue(uid); in TEST_F()
607 uint32_t uid = TEST_UID; in TEST_F() local
608 ASSERT_TRUE(isOk(mTc.updateOwnerMapEntry(STANDBY_MATCH, uid, DENY, DENYLIST))); in TEST_F()
609 Result<UidOwnerValue> value = mFakeUidOwnerMap.readValue(uid); in TEST_F()
613 ASSERT_TRUE(isOk(mTc.updateOwnerMapEntry(DOZABLE_MATCH, uid, ALLOW, ALLOWLIST))); in TEST_F()
614 value = mFakeUidOwnerMap.readValue(uid); in TEST_F()
618 ASSERT_TRUE(isOk(mTc.updateOwnerMapEntry(DOZABLE_MATCH, uid, DENY, ALLOWLIST))); in TEST_F()
619 value = mFakeUidOwnerMap.readValue(uid); in TEST_F()
623 ASSERT_TRUE(isOk(mTc.updateOwnerMapEntry(STANDBY_MATCH, uid, ALLOW, DENYLIST))); in TEST_F()
624 ASSERT_FALSE(mFakeUidOwnerMap.readValue(uid).ok()); in TEST_F()
626 uid = TEST_UID2; in TEST_F()
627 ASSERT_FALSE(isOk(mTc.updateOwnerMapEntry(STANDBY_MATCH, uid, ALLOW, DENYLIST))); in TEST_F()
628 ASSERT_FALSE(mFakeUidOwnerMap.readValue(uid).ok()); in TEST_F()