Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove invalid http:Request references from test cases #1081

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading