Commit 483ac964 authored by yangjian's avatar yangjian

Complete AuthenticationSubscription and Test successful

parent 47205f6f
......@@ -32,6 +32,7 @@ void AuthenticationSubscriptionDocumentApi::init() {
void AuthenticationSubscriptionDocumentApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Get(*router, base + "/subscription-data/:ueId/authentication-data/authentication-subscription", Routes::bind(&AuthenticationSubscriptionDocumentApi::read_authentication_subscription_handler, this));
Routes::Patch(*router, base + "/subscription-data/:ueId/authentication-data/authentication-subscription", Routes::bind(&AuthenticationSubscriptionDocumentApi::modify_authentication_subscription_handler, this));
// Default handler, called when a route is not found
......@@ -41,7 +42,10 @@ void AuthenticationSubscriptionDocumentApi::setupRoutes() {
void AuthenticationSubscriptionDocumentApi::modify_authentication_subscription_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
// Getting the path params
auto ueId = request.param(":ueId").as<std::string>();
std::cout<<"***** ueId ("<<ueId<<")******"<<std::endl;
std::cout<<"***** request.body() ("<<request.body()<<")******"<<std::endl;
// Getting the body param
std::vector<PatchItem> patchItem;
......@@ -73,6 +77,42 @@ void AuthenticationSubscriptionDocumentApi::modify_authentication_subscription_h
}
void AuthenticationSubscriptionDocumentApi::read_authentication_subscription_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response)
{
// Getting the path params
auto ueId = request.param(":ueId").as<std::string>();
std::cout<<"***** ueId ("<<ueId<<")******"<<std::endl;
std::cout<<"***** request.body() ("<<request.body()<<")******"<<std::endl;
// Getting the query params
auto supportedFeaturesQuery = request.query().get("supported-features");
Pistache::Optional<std::string> supportedFeatures;
if(!supportedFeaturesQuery.isEmpty()){
std::string valueQuery_instance;
if(fromStringValue(supportedFeaturesQuery.get(), valueQuery_instance)){
supportedFeatures = Pistache::Some(valueQuery_instance);
}
}
try {
this->read_authentication_subscription(ueId, supportedFeatures, response);
} catch (nlohmann::detail::exception &e) {
//send a 400 error
response.send(Pistache::Http::Code::Bad_Request, e.what());
return;
} catch (Pistache::Http::HttpError &e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception &e) {
//send a 500 error
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
return;
}
}
void AuthenticationSubscriptionDocumentApi::authentication_subscription_document_api_default_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
response.send(Pistache::Http::Code::Not_Found, "The requested method does not exist");
}
......
......@@ -50,6 +50,7 @@ private:
void setupRoutes();
void modify_authentication_subscription_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void read_authentication_subscription_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void authentication_subscription_document_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
std::shared_ptr<Pistache::Rest::Router> router;
......@@ -64,6 +65,7 @@ private:
/// <param name="patchItem"></param>
/// <param name="supportedFeatures">Features required to be supported by the target NF (optional, default to &quot;&quot;)</param>
virtual void modify_authentication_subscription(const std::string &ueId, const std::vector<PatchItem> &patchItem, const Pistache::Optional<std::string> &supportedFeatures, Pistache::Http::ResponseWriter &response) = 0;
virtual void read_authentication_subscription(const std::string &ueId, const Pistache::Optional<std::string> &supportedFeatures, Pistache::Http::ResponseWriter &response) = 0;
};
......
......@@ -25,6 +25,7 @@ AccessAndMobilitySubscriptionDataDocumentApiImpl::AccessAndMobilitySubscriptionD
void AccessAndMobilitySubscriptionDataDocumentApiImpl::query_am_data(const std::string &ueId, const std::string &servingPlmnId, const Pistache::Optional<std::vector<std::string>> &fields, const Pistache::Optional<std::string> &supportedFeatures, const Pistache::Optional<Pistache::Http::Header::Raw> &ifNoneMatch, const Pistache::Optional<Pistache::Http::Header::Raw> &ifModifiedSince, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
}
......
......@@ -11,6 +11,7 @@
*/
#include "AuthenticationSubscriptionDocumentApiImpl.h"
#include "PatchResult.h"
namespace org {
namespace openapitools {
......@@ -24,9 +25,40 @@ AuthenticationSubscriptionDocumentApiImpl::AuthenticationSubscriptionDocumentApi
{ }
void AuthenticationSubscriptionDocumentApiImpl::modify_authentication_subscription(const std::string &ueId, const std::vector<PatchItem> &patchItem, const Pistache::Optional<std::string> &supportedFeatures, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
/************************ test ************************/
nlohmann::json j,j1;
for(int i=0;i<patchItem.size();i++)
{
to_json(j1,patchItem[i]);
j+=j1;
}
response.send(Pistache::Http::Code::Ok, j.dump());
//response.send(Pistache::Http::Code::Ok, "Do some magic hello\n");
/******************************************************/
//1.modify handler
//2.modify success
//3.send PatchResult
//response.send(Pistache::Http::Code::Ok, j.dump());
}
void AuthenticationSubscriptionDocumentApiImpl::read_authentication_subscription(const std::string &ueId, const Pistache::Optional<std::string> &supportedFeatures, Pistache::Http::ResponseWriter &response)
{
/************************ test ************************/
response.send(Pistache::Http::Code::Ok, "read_authentication_subscription");
//response.send(Pistache::Http::Code::Ok, "Do some magic hello\n");
/******************************************************/
//1.read handler database
//2.send data
//response.send(Pistache::Http::Code::Ok, j.dump());
}
}
}
}
......
......@@ -48,6 +48,7 @@ public:
~AuthenticationSubscriptionDocumentApiImpl() {}
void modify_authentication_subscription(const std::string &ueId, const std::vector<PatchItem> &patchItem, const Pistache::Optional<std::string> &supportedFeatures, Pistache::Http::ResponseWriter &response);
void read_authentication_subscription(const std::string &ueId, const Pistache::Optional<std::string> &supportedFeatures, Pistache::Http::ResponseWriter &response);
};
......
......@@ -22,14 +22,12 @@
#include "AMF3GPPAccessRegistrationDocumentApiImpl.h"
#include "AMFNon3GPPAccessRegistrationDocumentApiImpl.h"
//#include "AMFSubscriptionInfoDocumentApiImpl.h"
#include "AccessAndMobilityDataApiImpl.h"
#include "AccessAndMobilityPolicyDataDocumentApiImpl.h"
#include "AccessAndMobilitySubscriptionDataDocumentApiImpl.h"
#include "AmfSubscriptionInfoDocumentApiImpl.h"
#include "ApplicationDataSubscriptionsCollectionApiImpl.h"
#include "AuthEventDocumentApiImpl.h"
#include "AuthenticationDataDocumentApiImpl.h"
#include "AuthenticationSoRDocumentApiImpl.h"
#include "AuthenticationStatusDocumentApiImpl.h"
#include "AuthenticationSubscriptionDocumentApiImpl.h"
......@@ -168,8 +166,6 @@ int main() {
AMF3GPPAccessRegistrationDocumentApiserver.init();
AMFNon3GPPAccessRegistrationDocumentApiImpl AMFNon3GPPAccessRegistrationDocumentApiserver(router);
AMFNon3GPPAccessRegistrationDocumentApiserver.init();
// AMFSubscriptionInfoDocumentApiImpl AMFSubscriptionInfoDocumentApiserver(router);
// AMFSubscriptionInfoDocumentApiserver.init();
AccessAndMobilityDataApiImpl AccessAndMobilityDataApiserver(router);
AccessAndMobilityDataApiserver.init();
AccessAndMobilityPolicyDataDocumentApiImpl AccessAndMobilityPolicyDataDocumentApiserver(router);
......@@ -182,8 +178,6 @@ int main() {
ApplicationDataSubscriptionsCollectionApiserver.init();
AuthEventDocumentApiImpl AuthEventDocumentApiserver(router);
AuthEventDocumentApiserver.init();
AuthenticationDataDocumentApiImpl AuthenticationDataDocumentApiserver(router);
AuthenticationDataDocumentApiserver.init();
AuthenticationSoRDocumentApiImpl AuthenticationSoRDocumentApiserver(router);
AuthenticationSoRDocumentApiserver.init();
AuthenticationStatusDocumentApiImpl AuthenticationStatusDocumentApiserver(router);
......
......@@ -12,6 +12,8 @@
#include "PatchItem.h"
#include <iostream>
using namespace std;
namespace org {
namespace openapitools {
......@@ -49,6 +51,7 @@ void to_json(nlohmann::json& j, const PatchItem& o)
void from_json(const nlohmann::json& j, PatchItem& o)
{
cout<<"patchitem from_json "<<endl;
j.at("op").get_to(o.m_Op);
j.at("path").get_to(o.m_Path);
if(j.find("from") != j.end())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment