-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Azure Storage Turn on Fixed Tests #4422
Changes from 21 commits
66be278
5493c38
64643ab
c88a4c3
1ec9438
40a8ce2
78db8d4
69026ba
be429c3
e3f43d6
b00cdc6
da7ebb6
78ea66b
f65653f
248b3a9
f101d67
bf411bf
2e4ed28
81421d8
4bd07e6
ef2daa4
6cdd2d8
623611e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ import com.azure.core.util.configuration.ConfigurationManager | |
import com.azure.identity.credential.EnvironmentCredential | ||
import com.azure.storage.blob.models.* | ||
import com.azure.storage.common.credentials.SharedKeyCredential | ||
import io.netty.buffer.ByteBuf | ||
import org.junit.Assume | ||
import org.spockframework.lang.ISpecificationContext | ||
import reactor.core.publisher.Flux | ||
|
@@ -409,7 +410,7 @@ class APISpec extends Specification { | |
response.value().contentEncoding() == contentEncoding && | ||
response.value().contentLanguage() == contentLanguage && | ||
response.value().contentMD5() == contentMD5 && | ||
response.headers().value("Content-Type") == (contentType == null ? "application/octet-stream" : contentType) | ||
response.headers().value("Content-Type") == contentType | ||
} | ||
|
||
static Metadata getMetadataFromHeaders(HttpHeaders headers) { | ||
|
@@ -502,43 +503,51 @@ class APISpec extends Specification { | |
to play too nicely with mocked objects and the complex reflection stuff on both ends made it more difficult to work | ||
with than was worth it. Because this type is just for BlobDownload, we don't need to accept a header type. | ||
*/ | ||
def getStubResponseForBlobDownload(int code, Flux<ByteBuffer> body, String etag) { | ||
return new HttpResponse() { | ||
static class MockDownloadHttpResponse extends HttpResponse { | ||
private final int statusCode | ||
private final HttpHeaders headers | ||
private final Flux<ByteBuf> body | ||
|
||
MockDownloadHttpResponse(HttpResponse response, int statusCode, Flux<ByteBuf> body) { | ||
this.request(response.request()) | ||
this.statusCode = statusCode | ||
this.headers = response.headers() | ||
this.body = body | ||
} | ||
|
||
@Override | ||
int statusCode() { | ||
return code | ||
} | ||
@Override | ||
int statusCode() { | ||
return statusCode | ||
} | ||
|
||
@Override | ||
String headerValue(String s) { | ||
return null | ||
} | ||
@Override | ||
String headerValue(String s) { | ||
return headers.value(s) | ||
} | ||
|
||
@Override | ||
HttpHeaders headers() { | ||
return new HttpHeaders() | ||
} | ||
@Override | ||
HttpHeaders headers() { | ||
return headers | ||
} | ||
|
||
@Override | ||
Flux<ByteBuffer> body() { | ||
return body | ||
} | ||
@Override | ||
Flux<ByteBuf> body() { | ||
return body | ||
} | ||
|
||
@Override | ||
Mono<byte[]> bodyAsByteArray() { | ||
return null | ||
} | ||
@Override | ||
Mono<byte[]> bodyAsByteArray() { | ||
return Mono.error(new IOException()) | ||
} | ||
|
||
@Override | ||
Mono<String> bodyAsString() { | ||
return null | ||
} | ||
@Override | ||
Mono<String> bodyAsString() { | ||
return Mono.error(new IOException()) | ||
} | ||
|
||
@Override | ||
Mono<String> bodyAsString(Charset charset) { | ||
return null | ||
} | ||
@Override | ||
Mono<String> bodyAsString(Charset charset) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this necessary to have, it looks like a duplicate to the one above? Since it is a mock response, we can only include the necessary part. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have to include everything as it's implementing an interface, I should change extends -> implements |
||
return Mono.error(new IOException()) | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
package com.azure.storage.blob; | ||
|
||
import com.azure.core.util.configuration.ConfigurationManager; | ||
import com.azure.identity.credential.EnvironmentCredential; | ||
import com.azure.storage.blob.models.ContainerItem; | ||
import org.junit.BeforeClass; | ||
|
@@ -15,8 +16,9 @@ public class AadLoginTest { | |
|
||
@BeforeClass | ||
public static void setup() { | ||
String endpoint = String.format("https://%s.blob.core.windows.net", ConfigurationManager.getConfiguration().get("PRIMARY_STORAGE_ACCOUNT_KEY")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PRIMARY_STORAGE_ACCOUNT_KEY. It should be account name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class is being deleted in another PR |
||
storageClient = new BlobServiceClientBuilder() | ||
.endpoint("https://" + System.getenv("ACCOUNT_NAME") + ".blob.core.windows.net") | ||
.endpoint(endpoint) | ||
.credential(new EnvironmentCredential()) | ||
// .httpClient(HttpClient.createDefault().proxy(() -> new ProxyOptions(Type.HTTP, new InetSocketAddress("localhost", 8888)))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove this line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class is being deleted in another PR |
||
.buildClient(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,9 @@ class AppendBlobAPITest extends APISpec { | |
bu.create(headers, null, null, null) | ||
Response<BlobProperties> response = bu.getProperties() | ||
|
||
// If the value isn't set the service will automatically set it | ||
contentType = (contentType == null) ? "application/octet-stream" : contentType | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason you remove it from APISpec but added here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't true for all cases that used the method |
||
|
||
then: | ||
validateBlobProperties(response, cacheControl, contentDisposition, contentEncoding, contentLanguage, contentMD5, contentType) | ||
|
||
|
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.
Make return one line.