EXPECT_EQ(0, attrs.size());
}
+// Verifies add front.
+TEST_F(AttributeTest, attributesAddFront) {
+ Attributes attrs;
+ EXPECT_TRUE(attrs.empty());
+ EXPECT_EQ(0, attrs.size());
+
+ // Add 2 User-Name and a Service-Type at the front.
+ ASSERT_NO_THROW(attrs.add(Attribute::fromString(PW_USER_NAME, "foobar")));
+ ASSERT_NO_THROW(attrs.add(Attribute::fromString(PW_USER_NAME, "foo")));
+ ASSERT_NO_THROW(attrs.add(Attribute::fromInt(PW_SERVICE_TYPE, 20), false));
+
+ // Get front.
+ ASSERT_EQ(3, attrs.size());
+ ConstAttributePtr attr = *(attrs.begin());
+ ASSERT_TRUE(attr);
+ EXPECT_EQ(PW_SERVICE_TYPE, attr->getType());
+
+ // Check that the default is to insert at the back.
+ attrs.clear();
+ ASSERT_NO_THROW(attrs.add(Attribute::fromString(PW_USER_NAME, "foobar")));
+ ASSERT_NO_THROW(attrs.add(Attribute::fromString(PW_USER_NAME, "foo")));
+ ASSERT_NO_THROW(attrs.add(Attribute::fromInt(PW_SERVICE_TYPE, 20)));
+ ASSERT_EQ(3, attrs.size());
+ attr = *(attrs.begin());
+ ASSERT_TRUE(attr);
+ EXPECT_EQ(PW_USER_NAME, attr->getType());
+}
+
// Verifies append.
TEST_F(AttributeTest, attributesAppend) {
Attributes attrs;
// Check attributes.
EXPECT_EQ(44, size);
+ EXPECT_EQ(PW_MESSAGE_AUTHENTICATOR, receive_buffer_[AUTH_HDR_LEN]);
+ EXPECT_EQ(AUTH_VECTOR_LEN + 2, receive_buffer_[AUTH_HDR_LEN + 1]);
uint8_t expected[] = {
0x04, // NAS-IP-Address
0x06, // length
- 0x7f, 0x00, 0x00, 0x01, // 127.0.0.1
- 0x50, // Message-Authenticator
- 0x12 // length
+ 0x7f, 0x00, 0x00, 0x01 // 127.0.0.1
};
- EXPECT_EQ(0, memcmp(expected, &receive_buffer_[AUTH_HDR_LEN], 8));
+ EXPECT_EQ(0, memcmp(expected, &receive_buffer_[AUTH_HDR_LEN + 18], 6));
}
/// Verify that accounting IdleTimerCallback works as expected.
// Check attributes.
EXPECT_EQ(44, size);
+ EXPECT_EQ(PW_MESSAGE_AUTHENTICATOR, receive_buffer_[AUTH_HDR_LEN]);
+ EXPECT_EQ(AUTH_VECTOR_LEN + 2, receive_buffer_[AUTH_HDR_LEN + 1]);
uint8_t expected[] = {
0x04, // NAS-IP-Address
0x06, // length
- 0x7f, 0x00, 0x00, 0x01, // 127.0.0.1
- 0x50, // Message-Authenticator
- 0x12 // length
+ 0x7f, 0x00, 0x00, 0x01 // 127.0.0.1
};
- EXPECT_EQ(0, memcmp(expected, &receive_buffer_[AUTH_HDR_LEN], 8));
+ EXPECT_EQ(0, memcmp(expected, &receive_buffer_[AUTH_HDR_LEN + 18], 6));
}
/// Verify that access idle timer works as expected.
// Check attributes.
EXPECT_EQ(44, size);
+ EXPECT_EQ(PW_MESSAGE_AUTHENTICATOR, receive_buffer_[AUTH_HDR_LEN]);
+ EXPECT_EQ(AUTH_VECTOR_LEN + 2, receive_buffer_[AUTH_HDR_LEN + 1]);
uint8_t expected[] = {
0x04, // NAS-IP-Address
0x06, // length
- 0x7f, 0x00, 0x00, 0x01, // 127.0.0.1
- 0x50, // Message-Authenticator
- 0x12 // length
+ 0x7f, 0x00, 0x00, 0x01 // 127.0.0.1
};
- EXPECT_EQ(0, memcmp(expected, &receive_buffer_[AUTH_HDR_LEN], 8));
+ EXPECT_EQ(0, memcmp(expected, &receive_buffer_[AUTH_HDR_LEN + 18], 6));
}
/// Verify that accounting idle timer works as expected.
// Check attributes.
EXPECT_EQ(44, size);
+ EXPECT_EQ(PW_MESSAGE_AUTHENTICATOR, receive_buffer_[AUTH_HDR_LEN]);
+ EXPECT_EQ(AUTH_VECTOR_LEN + 2, receive_buffer_[AUTH_HDR_LEN + 1]);
uint8_t expected[] = {
0x04, // NAS-IP-Address
0x06, // length
- 0x7f, 0x00, 0x00, 0x01, // 127.0.0.1
- 0x50, // Message-Authenticator
- 0x12 // length
+ 0x7f, 0x00, 0x00, 0x01 // 127.0.0.1
};
- EXPECT_EQ(0, memcmp(expected, &receive_buffer_[AUTH_HDR_LEN], 8));
+ EXPECT_EQ(0, memcmp(expected, &receive_buffer_[AUTH_HDR_LEN + 18], 6));
}
} // end of anonymous namespace