-
Notifications
You must be signed in to change notification settings - Fork 50
Handle GCP project not found #1092
Conversation
// GCP returns 403 in case of project not found for security reason, but that makes it impossible | ||
// to differentiate that from missing permission; we take the risk here assuming Styx service account does have | ||
// proper permissions | ||
if (e.getStatusCode() == FORBIDDEN.code()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Real change.
if (cause instanceof GoogleJsonResponseException | ||
&& ((GoogleJsonResponseException) cause).getStatusCode() == 404) { | ||
&& ((GoogleJsonResponseException) cause).getStatusCode() == FORBIDDEN.code()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Real change.
@@ -37,7 +39,7 @@ | |||
import static org.mockito.Mockito.reset; | |||
import static org.mockito.Mockito.times; | |||
import static org.mockito.Mockito.verify; | |||
import static org.mockito.Mockito.verifyZeroInteractions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is deprecated.
Codecov Report
@@ Coverage Diff @@
## master #1092 +/- ##
============================================
+ Coverage 92.33% 92.37% +0.03%
- Complexity 2150 2152 +2
============================================
Files 200 200
Lines 8326 8325 -1
Branches 504 504
============================================
+ Hits 7688 7690 +2
+ Misses 522 521 -1
+ Partials 116 114 -2 |
styx-service-common/src/main/java/com/spotify/styx/api/Authenticator.java
Outdated
Show resolved
Hide resolved
styx-service-common/src/main/java/com/spotify/styx/api/Authenticator.java
Outdated
Show resolved
Hide resolved
…icator.java Co-authored-by: sonjaer <[email protected]>
styx-service-common/src/main/java/com/spotify/styx/api/ServiceAccountUsageAuthorizer.java
Outdated
Show resolved
Hide resolved
…AccountUsageAuthorizer.java
styx-service-common/src/test/java/com/spotify/styx/api/ServiceAccountUsageAuthorizerTest.java
Show resolved
Hide resolved
@@ -20,6 +20,8 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no test we need to change for the 404->403 code change in styx-service-common/src/main/java/com/spotify/styx/api/Authenticator.java ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/spotify/styx/pull/1092/files#diff-6d62dc7647527de82216a154436bab32cb014d6a27fc005028168031ea1a95f2R313-R332f those are the changes. There is no externally observable difference though because we treat exceptions the same except the logging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah true
Hey, I just made a Pull Request!
Description
Handle GCP project not found correctly.
Motivation and Context
GCP will never return 404 in case of project not found, due to security reason. So we need to treat 403 as 404 for some case.
I also did some small refactorings along the way.
Have you tested this? If so, how?
I updated existing tests to reflect this change.
Checklist for PR author(s)
Checklist for PR reviewer(s)