Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
90eb388c
Commit
90eb388c
authored
8 years ago
by
Jan Tattermusch
Browse files
Options
Downloads
Patches
Plain Diff
add more MetadataCredentials tests
parent
ae4ab4fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs
+27
-0
27 additions, 0 deletions
...csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs
with
27 additions
and
0 deletions
src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs
+
27
−
0
View file @
90eb388c
...
...
@@ -103,6 +103,33 @@ namespace Grpc.IntegrationTesting
client
.
UnaryCall
(
new
SimpleRequest
{
},
new
CallOptions
(
credentials
:
callCredentials
));
}
[
Test
]
public
void
MetadataCredentials_InterceptorLeavesMetadataEmpty
()
{
var
channelCredentials
=
ChannelCredentials
.
Create
(
TestCredentials
.
CreateSslCredentials
(),
CallCredentials
.
FromInterceptor
(
new
AsyncAuthInterceptor
((
context
,
metadata
)
=>
TaskUtils
.
CompletedTask
)));
channel
=
new
Channel
(
Host
,
server
.
Ports
.
Single
().
BoundPort
,
channelCredentials
,
options
);
client
=
new
TestService
.
TestServiceClient
(
channel
);
var
ex
=
Assert
.
Throws
<
RpcException
>(()
=>
client
.
UnaryCall
(
new
SimpleRequest
{
}));
Assert
.
AreEqual
(
StatusCode
.
Unknown
,
ex
.
Status
.
StatusCode
);
}
[
Test
]
public
void
MetadataCredentials_InterceptorThrows
()
{
var
callCredentials
=
CallCredentials
.
FromInterceptor
(
new
AsyncAuthInterceptor
((
context
,
metadata
)
=>
{
throw
new
Exception
(
"Auth interceptor throws"
);
}));
var
channelCredentials
=
ChannelCredentials
.
Create
(
TestCredentials
.
CreateSslCredentials
(),
callCredentials
);
channel
=
new
Channel
(
Host
,
server
.
Ports
.
Single
().
BoundPort
,
channelCredentials
,
options
);
client
=
new
TestService
.
TestServiceClient
(
channel
);
var
ex
=
Assert
.
Throws
<
RpcException
>(()
=>
client
.
UnaryCall
(
new
SimpleRequest
{
}));
Assert
.
AreEqual
(
StatusCode
.
Unauthenticated
,
ex
.
Status
.
StatusCode
);
}
private
class
FakeTestService
:
TestService
.
TestServiceBase
{
public
override
Task
<
SimpleResponse
>
UnaryCall
(
SimpleRequest
request
,
ServerCallContext
context
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment