-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add grpc endpoint test harness
- Loading branch information
Showing
5 changed files
with
105 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
kotlin.code.style=official | ||
ktor_version=2.3.12 | ||
kotlin_version=2.0.20 | ||
logback_version=1.4.14 | ||
ktorVersion=2.3.12 | ||
kotlinVersion=2.0.20 | ||
logbackVersion=1.4.14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.stabledata | ||
|
||
import com.stabledata.context.StableEventIdHeader | ||
import com.stabledata.grpc.SchemaService | ||
import io.grpc.Metadata | ||
import io.kotest.core.spec.style.WordSpec | ||
import io.ktor.http.* | ||
import stable.Schema | ||
import stable.SchemaServiceGrpc | ||
|
||
class SchemaGrpcTest:WordSpec({ | ||
"returns unauthorized" should { | ||
grpcTest( | ||
serviceImpl = SchemaService(), | ||
stubCreator = { channel -> SchemaServiceGrpc.newBlockingStub(channel) } | ||
) { stub -> | ||
|
||
val metadata = Metadata().apply { | ||
put(Metadata.Key.of(HttpHeaders.Authorization, Metadata.ASCII_STRING_MARSHALLER), "Bearer some-token") | ||
put(Metadata.Key.of(StableEventIdHeader, Metadata.ASCII_STRING_MARSHALLER), "12345") | ||
} | ||
|
||
// Create a call options object to pass the metadata interceptor | ||
val callOptions = stub.withInterceptors(MetadataInterceptor(metadata)) | ||
|
||
val request = Schema.CollectionRequest.newBuilder() | ||
.setId("collection-123") | ||
.setPath("/example/path") | ||
.build() | ||
|
||
val response = callOptions.createCollection(request) | ||
assert(response != null) | ||
} | ||
|
||
} | ||
}) |