diff --git a/include/faker-cxx/Internet.h b/include/faker-cxx/Internet.h index b2ce12ba6..cee447e2f 100644 --- a/include/faker-cxx/Internet.h +++ b/include/faker-cxx/Internet.h @@ -172,6 +172,28 @@ class Internet */ static unsigned httpStatusCode(std::optional responseType = std::nullopt); + /** + * @brief Generates a random http request header. + * + * @returns Http request header. + * + * @code + * Internet::httpRequestHeader() // "Authorization" + * @endcode + */ + static std::string httpRequestHeader(); + + /** + * @brief Generates a random http response header. + * + * @returns Http response header. + * + * @code + * Internet::httpResponseHeader() // "Location" + * @endcode + */ + static std::string httpResponseHeader(); + /** * @brief Returns a string containing randomized ipv4 address of the given class. * diff --git a/src/modules/internet/Internet.cpp b/src/modules/internet/Internet.cpp index 777cf1360..cbdf7d77c 100644 --- a/src/modules/internet/Internet.cpp +++ b/src/modules/internet/Internet.cpp @@ -7,6 +7,8 @@ #include "data/DomainSuffixes.h" #include "data/EmailHosts.h" #include "data/Emojis.h" +#include "data/HttpRequestHeaders.h" +#include "data/HttpResponseHeaders.h" #include "faker-cxx/Helper.h" #include "faker-cxx/Person.h" #include "faker-cxx/String.h" @@ -167,6 +169,16 @@ unsigned Internet::httpStatusCode(std::optional responseType) return Helper::arrayElement(statusCodes); } +std::string Internet::httpRequestHeader() +{ + return Helper::arrayElement(httpRequestHeaders); +} + +std::string Internet::httpResponseHeader() +{ + return Helper::arrayElement(httpResponseHeaders); +} + std::string Internet::ipv4(IPv4Class ipv4class) { IPv4Address sectors; diff --git a/src/modules/internet/InternetTest.cpp b/src/modules/internet/InternetTest.cpp index deb387ac8..43ce43cc4 100644 --- a/src/modules/internet/InternetTest.cpp +++ b/src/modules/internet/InternetTest.cpp @@ -16,6 +16,8 @@ #include "data/DomainSuffixes.h" #include "data/EmailHosts.h" #include "data/Emojis.h" +#include "data/HttpRequestHeaders.h" +#include "data/HttpResponseHeaders.h" using namespace ::testing; using namespace faker; @@ -533,6 +535,22 @@ TEST_F(InternetTest, shouldGenerateHttpStatusCode) { return generatedHttpStatusCode == statusCode; })); } +TEST_F(InternetTest, shouldGenerateHttpRequestHeader) +{ + const auto generatedHttpRequestHeader = Internet::httpRequestHeader(); + + ASSERT_TRUE(std::ranges::any_of(httpRequestHeaders, [generatedHttpRequestHeader](const std::string& httpHeader) + { return generatedHttpRequestHeader == httpHeader; })); +} + +TEST_F(InternetTest, shouldGenerateHttpResponseHeader) +{ + const auto generatedHttpResponseHeader = Internet::httpResponseHeader(); + + ASSERT_TRUE(std::ranges::any_of(httpResponseHeaders, [generatedHttpResponseHeader](const std::string& httpHeader) + { return generatedHttpResponseHeader == httpHeader; })); +} + TEST_F(InternetTest, shouldGenerateHttpInformationalSuccessCode) { const auto generatedHttpStatusCode = Internet::httpStatusCode(HttpResponseType::Informational); diff --git a/src/modules/internet/data/EmailHosts.h b/src/modules/internet/data/EmailHosts.h index 9249da6c7..f7ada7e45 100644 --- a/src/modules/internet/data/EmailHosts.h +++ b/src/modules/internet/data/EmailHosts.h @@ -5,12 +5,7 @@ namespace faker { -const std::vector emailHosts = { - "gmail.com", - "yahoo.com", - "hotmail.com", - "outlook.com", -}; +const std::vector emailHosts = {"gmail.com", "yahoo.com", "hotmail.com", "outlook.com"}; const std::vector emailExampleHosts = {"example.org", "example.com", "example.net"}; diff --git a/src/modules/internet/data/HttpRequestHeaders.h b/src/modules/internet/data/HttpRequestHeaders.h new file mode 100644 index 000000000..df32c2f9a --- /dev/null +++ b/src/modules/internet/data/HttpRequestHeaders.h @@ -0,0 +1,49 @@ +#pragma once + +#include +#include + +namespace faker +{ +const std::vector httpRequestHeaders = {"A-IM", + "Accept", + "Accept-Charset", + "Accept-Datetime", + "Accept-Encoding", + "Accept-Language", + "Access-Control-Request-Method", + "Access-Control-Request-Headers", + "Authorization", + "Cache-Control", + "Connection", + "Content-Encoding", + "Content-Length", + "Content-MD5", + "Content-Type", + "Cookie", + "Date", + "Expect", + "Forwarded", + "From", + "Host", + "HTTP2-Settings", + "If-Match", + "If-Modified-Since", + "If-None-Match", + "If-Range", + "If-Unmodified-Since", + "Max-Forwards", + "Origin", + "Pragma", + "Prefer", + "Proxy-Authorization", + "Range", + "Referer", + "TE", + "Transfer-Encoding", + "User-Agent", + "Upgrade", + "Upgrade", + "Via", + "Warning"}; +} diff --git a/src/modules/internet/data/HttpResponseHeaders.h b/src/modules/internet/data/HttpResponseHeaders.h new file mode 100644 index 000000000..2649fb175 --- /dev/null +++ b/src/modules/internet/data/HttpResponseHeaders.h @@ -0,0 +1,52 @@ +#pragma once + +#include +#include + +namespace faker +{ +const std::vector httpResponseHeaders = {"Accept-CH", + "Access-Control-Allow-Origin", + "Access-Control-Allow-Credentials", + "Access-Control-Expose-Headers", + "Access-Control-Max-Age", + "Access-Control-Allow-Methods", + "Access-Control-Allow-HeadersAccess-Control-Allow-Origin", + "Accept-Patch", + "Accept-Ranges", + "Age", + "Allow", + "Alt-Svc", + "Cache-Control", + "Connection", + "Content-Disposition", + "Content-Encoding", + "Content-Language", + "Content-Length", + "Content-Location", + "Content-MD5", + "Content-Range", + "Content-Type", + "Date", + "Delta-Base", + "ETag", + "Expires", + "IM", + "Last-Modified", + "Location", + "P3P", + "Pragma", + "Preference-Applied", + "Proxy-Authenticate", + "Public-Key-Pins", + "Retry-After", + "Server", + "Set-Cookie", + "Strict-Transport-Security", + "Transfer-Encoding", + "Tk", + "Upgrade", + "Vary", + "Warning", + "WWW-Authenticate"}; +} diff --git a/src/modules/person/data/nepalese/NepaleseFirstNamesMales.h b/src/modules/person/data/nepalese/NepaleseFirstNamesMales.h index d1e65ef2a..4e7413f1e 100644 --- a/src/modules/person/data/nepalese/NepaleseFirstNamesMales.h +++ b/src/modules/person/data/nepalese/NepaleseFirstNamesMales.h @@ -8,17 +8,17 @@ namespace faker const std::vector nepaleseFirstNamesMales = { - "Sijan", "Prabesh", "Niwang", "Nabin", "Sanjok", "Bibek", "Sujal", "Sagar", "Mukunda", "Arun", - "Nirdesh", "Rabin", "Ramesh", "Manoj", "Bimal", "Anil", "Bipin", "Gopal", "Sunil", "Bikash", - "Sujan", "Sudeep", "Nikhil", "Nishant", "Kiran", "Pramod", "Saroj", "Rajesh", "Dilip", "Sandesh", - "Krishna", "Hari", "Suresh", "Arjun", "Bibash", "Rajiv", "Rajendra", "Bijay", "Aashish", "Raju", - "Sabin", "Keshav", "Rabi", "Sanjeev", "Puspa", "Saroj", "Khem", "Shiva", "Mohan", "Dinesh", - "Rajendra", "Suman", "Ujjwal", "Bhuwan", "Birendra", "Birat", "Lalit", "Bhola", "Pradip", "Nabin", - "Suman", "Shankar", "Laxman", "Sushant", "Roshan", "Buddha", "Kapil", "Rajbir", "Suraj", "Raj Kumar", - "Manish", "Ajay", "Dipak", "Anish", "Sabin", "Prem", "Bijay", "Narayan", "Rajat", "Rishi", - "Yogesh", "Rajendra", "Pawan", "Bhawesh", "Pramod", "Pramod", "Saurav", "Hemant", "Subash", "Sparsha", - "Sabin", "Manohar", "Anuj", "Aryan", "Yogendra", "Nischal", "Samir", "Sanjay", "Bijay", "Rohit", - "Rajat", "Biraj", "Kiran", "Pravin", "Pramod" + "Sijan", "Prabesh", "Niwang", "Nabin", "Sanjok", "Bibek", "Sujal", "Sagar", "Mukunda", "Arun", + "Nirdesh", "Rabin", "Ramesh", "Manoj", "Bimal", "Anil", "Bipin", "Gopal", "Sunil", "Bikash", + "Sujan", "Sudeep", "Nikhil", "Nishant", "Kiran", "Pramod", "Saroj", "Rajesh", "Dilip", "Sandesh", + "Krishna", "Hari", "Suresh", "Arjun", "Bibash", "Rajiv", "Rajendra", "Bijay", "Aashish", "Raju", + "Sabin", "Keshav", "Rabi", "Sanjeev", "Puspa", "Saroj", "Khem", "Shiva", "Mohan", "Dinesh", + "Rajendra", "Suman", "Ujjwal", "Bhuwan", "Birendra", "Birat", "Lalit", "Bhola", "Pradip", "Nabin", + "Suman", "Shankar", "Laxman", "Sushant", "Roshan", "Buddha", "Kapil", "Rajbir", "Suraj", "Manish", + "Ajay", "Dipak", "Anish", "Sabin", "Prem", "Bijay", "Narayan", "Rajat", "Rishi", "Yogesh", + "Rajendra", "Pawan", "Bhawesh", "Pramod", "Pramod", "Saurav", "Hemant", "Subash", "Sparsha", "Sabin", + "Manohar", "Anuj", "Aryan", "Yogendra", "Nischal", "Samir", "Sanjay", "Bijay", "Rohit", "Rajat", + "Biraj", "Kiran", "Pravin", "Pramod" };