Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #187 from NIFCloud-mbaas/develop
Browse files Browse the repository at this point in the history
 リリース 3.0.1 (DEV->MASTER)
  • Loading branch information
gs0zk1 authored Jan 17, 2019
2 parents ce9d299 + c090411 commit ee91ac4
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 6 deletions.
4 changes: 2 additions & 2 deletions NCMB.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "NCMB"
s.version = "3.0.0"
s.version = "3.0.1"
s.summary = "NCMB is SDK for NIFCLOUD mobile backend."
s.description = <<-DESC
NCMB is SDK for NIFCLOUD mobile backend.
Expand All @@ -15,7 +15,7 @@ Pod::Spec.new do |s|
s.license = "Apache License, Version 2.0"
s.author = "FUJITSU CLOUD TECHNOLOGIES LIMITED"
s.platform = :ios, "5.1"
s.source = { :git => 'https://github.com/NIFCloud-mbaas/ncmb_ios.git', :tag => 'v3.0.0' }
s.source = { :git => 'https://github.com/NIFCloud-mbaas/ncmb_ios.git', :tag => 'v3.0.1' }
s.source_files = "NCMB/**/*.{h,m,c}"
s.frameworks = "Foundation", "UIKit", "MobileCoreServices", "AudioToolbox", "SystemConfiguration"
s.requires_arc = true
Expand Down
2 changes: 1 addition & 1 deletion NCMB/NCMBConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#pragma mark - error
#define ERRORDOMAIN @"NCMBErrorDomain"
#define SDK_VERSION @"3.0.0"
#define SDK_VERSION @"3.0.1"

#define DATA_MAIN_PATH [NSHomeDirectory() stringByAppendingPathComponent:@"Library/"]
#define COMMAND_CACHE_FOLDER_PATH [NSString stringWithFormat:@"%@/Private Documents/NCMB/Command Cache/", DATA_MAIN_PATH]
Expand Down
1 change: 1 addition & 0 deletions NCMB/NCMBRequest/NCMBRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface NCMBRequest : NSMutableURLRequest

Expand Down
7 changes: 7 additions & 0 deletions NCMB/NCMBRequest/NCMBRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
static NSString *const sessionTokenField = @"X-NCMB-Apps-Session-Token";
static NSString *const signatureMethod = @"SignatureMethod=HmacSHA256";
static NSString *const signatureVersion = @"SignatureVersion=2";
static NSString *const kSDKVersionFieldName = @"X-NCMB-SDK-Version";
static NSString *const kOSVersionFieldName = @"X-NCMB-OS-Version";

@implementation NCMBRequest

Expand Down Expand Up @@ -66,6 +68,11 @@ -(instancetype)initWithURL:(NSURL *)url
if ([method isEqualToString:@"POST"] || [method isEqualToString:@"PUT"]) {
self.HTTPBody = bodyData;
}
// Set SDK and OS version
NSString *osVersion = [[UIDevice currentDevice] systemVersion];
[self setValue:[NSString stringWithFormat:@"ios-%@", osVersion] forHTTPHeaderField:kOSVersionFieldName];
[self setValue:[NSString stringWithFormat:@"ios-%@", SDK_VERSION] forHTTPHeaderField:kSDKVersionFieldName];

return self;
}

Expand Down
2 changes: 1 addition & 1 deletion NCMB/NCMBUser.m
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ - (void)afterFetch:(NSMutableDictionary *)response isRefresh:(BOOL)isRefresh{
if ([response objectForKey:@"sessionToken"]) {
self.sessionToken = [response objectForKey:@"sessionToken"];
}
[super afterFetch:response isRefresh:isRefresh];
[super afterFetch:response isRefresh:YES];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion NCMB/NCMB_Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.0.0</string>
<string>3.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion NCMBTests/NCMBTests/NCMBInstallationSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ -(NSMutableDictionary *)beforeConnection;
},
@"applicationName" : @"aaaa",
@"objectId" : @"EVMu2ne7bjzZhOW2",
@"sdkVersion" : @"3.0.0"
@"sdkVersion" : @"3.0.1"
};

NSDictionary *responseInstallation = @{@"channels" : @[
Expand Down
5 changes: 5 additions & 0 deletions NCMBTests/NCMBTests/NCMBRequestSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
expect([headers objectForKey:@"X-NCMB-Apps-Session-Token"]).to.equal(expectSessionToken);

expect([headers objectForKey:@"Content-Type"]).to.equal(@"application/json");

expect([headers objectForKey:@"X-NCMB-SDK-Version"]).to.equal([NSString stringWithFormat:@"ios-%@", SDK_VERSION]);

NSString *osVersion = [[UIDevice currentDevice] systemVersion];
expect([headers objectForKey:@"X-NCMB-OS-Version"]).to.equal([NSString stringWithFormat:@"ios-%@", osVersion]);


});
Expand Down
82 changes: 82 additions & 0 deletions NCMBTests/NCMBTests/NCMBUserSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#import <OCMock/OCMock.h>
#import <NCMB/NCMB.h>
#import <OHHTTPStubs/OHHTTPStubs.h>
#import <OHHTTPStubs/NSURLRequest+HTTPBodyTesting.h>

@interface NCMBUser (Private)
-(void)afterSave:(NSDictionary*)response operations:(NSMutableDictionary *)operations;
Expand Down Expand Up @@ -1218,6 +1219,87 @@ -(NSMutableDictionary *)beforeConnection;
}];
});
});

it(@"should reset operationSetQueue after fetch", ^{

[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
return [request.URL.host isEqualToString:@"mbaas.api.nifcloud.com"];
} withStubResponse:^OHHTTPStubsResponse*(NSURLRequest *request) {

NSMutableDictionary *responseDic = [@{@"createDate" : @"2014-06-03T11:28:30.348Z",
@"objectId" : @"e4YWYnYtcptTIV23",
@"sessionToken" : @"yDCY0ggL8hZghFQ70aiutHtJL",
@"userName" : @"admin"
} mutableCopy];

NSError *convertErr = nil;
NSData *responseData = [NSJSONSerialization dataWithJSONObject:responseDic
options:0
error:&convertErr];
return [OHHTTPStubsResponse responseWithData:responseData statusCode:201 headers:@{@"Content-Type":@"application/json;charset=UTF-8"}];
}];

waitUntil(^(DoneCallback done) {
// 1.ログインする
[NCMBUser logInWithUsernameInBackground:@"admin" password:@"123456" block:^(NCMBUser *user, NSError *error) {

expect(error).beNil();
NCMBUser *currentUser = NCMBUser.currentUser;
expect(currentUser).notTo.beNil();

NSDictionary *responseDic = @{ @"objectId" : @"e4YWYnYtcptTIV23",
@"userName" : @"admin",
@"mailAddress" : @"[email protected]",
@"createDate" : @"2014-06-03T11:28:30.348Z",
@"updateDate" : @"2014-06-03T11:28:30.348Z",
@"acl" : @{@"*":@{@"read":@true,@"write":@true}}} ;

NSData *responseData = [NSJSONSerialization dataWithJSONObject:responseDic options:NSJSONWritingPrettyPrinted error:nil];

[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
return [request.URL.host isEqualToString:@"mbaas.api.nifcloud.com"];
} withStubResponse:^OHHTTPStubsResponse*(NSURLRequest *request) {
return [OHHTTPStubsResponse responseWithData:responseData statusCode:200 headers:@{@"Content-Type":@"application/json;charset=UTF-8"}];
}];

currentUser = [NCMBUser currentUser];
// 2. fetchInBackgroundWithBlock
[currentUser fetchInBackgroundWithBlock:^(NSError *error) {
expect(error).beNil();
expect(currentUser.objectId).to.equal(@"e4YWYnYtcptTIV23");
[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
return [request.URL.host isEqualToString:@"mbaas.api.nifcloud.com"];
} withStubResponse:^OHHTTPStubsResponse*(NSURLRequest *request) {
NSData* body = request.OHHTTPStubs_HTTPBody;
NSString* bodyString = [[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding];

if (!([request.HTTPMethod isEqualToString:@"PUT"] && [bodyString isEqualToString:@"{\"userName\":\"updateUserName\"}"])) {
NSDictionary *responseDicError = @{ @"code" : @"E403001",
@"error" : @"Wrong body params."} ;
NSData *responseDataError = [NSJSONSerialization dataWithJSONObject:responseDicError options:NSJSONWritingPrettyPrinted error:nil];
return [OHHTTPStubsResponse responseWithData:responseDataError statusCode:403 headers:@{@"Content-Type":@"application/json;charset=UTF-8"}];
}

NSMutableDictionary *responseDic = [@{
@"updateDate" : @"2017-07-10T02:37:54.917Z",
} mutableCopy];
NSError *convertErr = nil;
NSData *responseData = [NSJSONSerialization dataWithJSONObject:responseDic
options:0
error:&convertErr];
return [OHHTTPStubsResponse responseWithData:responseData statusCode:201 headers:@{@"Content-Type":@"application/json;charset=UTF-8"}];
}];
currentUser.userName = @"updateUserName";
// 3.カレントユーザーが変更する
[currentUser saveInBackgroundWithBlock:^(NSError *error) {
expect(error).beNil();
done();
}];
}];

}];
});
});

it(@"signUpInBackgroundWithBlock system test", ^{
NSDictionary *responseDic = @{ @"objectId" : @"epaKcaYZqsREdSMY",
Expand Down

0 comments on commit ee91ac4

Please sign in to comment.