Skip to content

Commit

Permalink
Merge pull request #1081 from ayeshLK/dev
Browse files Browse the repository at this point in the history
Remove invalid `http:Request` references from test cases
  • Loading branch information
ayeshLK authored Feb 17, 2025
2 parents cbed44d + e5b675f commit 729c4e2
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions ballerina/tests/hub_authentication_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -39,39 +39,39 @@ final http:ListenerJwtAuthHandler handler = new({

service /websubhub on securedListener {

remote function onRegisterTopic(TopicRegistration message, http:Request req)
remote function onRegisterTopic(TopicRegistration message, http:Headers headers)
returns TopicRegistrationSuccess|TopicRegistrationError {
string? auth = doAuth(req);
string? auth = doAuth(headers);
if (auth is string) {
return error TopicRegistrationError(auth, statusCode = http:STATUS_UNAUTHORIZED);
}
log:printDebug("Received topic-registration request ", message = message);
return TOPIC_REGISTRATION_SUCCESS;
}

remote function onDeregisterTopic(TopicDeregistration message, http:Request req)
remote function onDeregisterTopic(TopicDeregistration message, http:Headers headers)
returns TopicDeregistrationSuccess|TopicDeregistrationError {
string? auth = doAuth(req);
string? auth = doAuth(headers);
if (auth is string) {
return error TopicDeregistrationError(auth, statusCode = http:STATUS_UNAUTHORIZED);
}
log:printDebug("Received topic-deregistration request ", message = message);
return TOPIC_DEREGISTRATION_SUCCESS;
}

remote function onUpdateMessage(UpdateMessage message, http:Request req)
remote function onUpdateMessage(UpdateMessage message, http:Headers headers)
returns Acknowledgement|UpdateMessageError {
string? auth = doAuth(req);
string? auth = doAuth(headers);
if (auth is string) {
return error UpdateMessageError(auth, statusCode = http:STATUS_UNAUTHORIZED);
}
log:printDebug("Received content-update request ", message = message);
return ACKNOWLEDGEMENT;
}

remote function onSubscription(Subscription message, http:Request req)
remote function onSubscription(Subscription message, http:Headers headers)
returns SubscriptionAccepted|InternalSubscriptionError {
string? auth = doAuth(req);
string? auth = doAuth(headers);
if (auth is string) {
return error InternalSubscriptionError(auth, statusCode = http:STATUS_UNAUTHORIZED);
}
Expand All @@ -82,9 +82,9 @@ service /websubhub on securedListener {
isolated remote function onSubscriptionIntentVerified(VerifiedSubscription message) {
}

remote function onUnsubscription(Unsubscription message, http:Request req)
remote function onUnsubscription(Unsubscription message, http:Headers headers)
returns UnsubscriptionAccepted|InternalUnsubscriptionError {
string? auth = doAuth(req);
string? auth = doAuth(headers);
if (auth is string) {
return error InternalUnsubscriptionError(auth, statusCode = http:STATUS_UNAUTHORIZED);
}
Expand All @@ -96,8 +96,8 @@ service /websubhub on securedListener {
}
}

isolated function doAuth(http:Request req) returns string? {
jwt:Payload|http:Unauthorized authn = handler.authenticate(req);
isolated function doAuth(http:Headers headers) returns string? {
jwt:Payload|http:Unauthorized authn = handler.authenticate(headers);
if (authn is http:Unauthorized) {
string errorMsg = "Failed to authenticate the request. " + <string>authn?.body;
log:printError(errorMsg);
Expand Down

0 comments on commit 729c4e2

Please sign in to comment.